Header tag

Monday, 30 May 2016

How many photographs (permutations including zero)

My wife and I have recently had our third child - hence I've not been blogging much lately.  However, I've been thinking about blog ideas, or more specifically, I've been thinking of mathematical investigations that I could explore and then, if they were interesting, share on my blog.

Our house is full of family photographs - almost every room has family photographs in it - and in particular on one wall, we have three photographs:  one of our daughter; one of our older son, and one of the two of them together.

In mathematical notation, let's call my daughter A and my older son B; so we have A, B and AB.

Now we have three children, and I have started considering how many photos we would need to show the same range of variations... and it's more than I thought.  Let's introduce the baby as C.

We would have:
A, B, C - each child individually
AB, AC, BC - each child with one other sibling
ABC - all three children together.

So the total number of pictures has gone from 3 to 7.

Let's suppose we have four children, A, B, C and D, and we want the same range of photos, with all variations.  The list grows dramatically:

A, B, C and D - individual photos - 4
AB, AC, AD, BC, BD, CD - pairs - 6
ABC, ABD, ACD, BCD - trios - 4
ABCD - group - 1
Total = 15

Children  Photos
1   1
2   3
3   7
4   15

In order to work out the nature of the series, I looked at the differences between terms, and then the second differences (i.e. the differences between the differences).
3-1 = 2
7-3 = 4
15-7 = 8

4-2=2
8-4 = 4

What became clear to me at this point is that the sequence is expanding exponentially or logarithmically, and not quadratically.  And then it very quickly followed that each nth term is 2n -1 (the series 2n is immediately recognisable - 1, 2, 4, 8, 16, 32 etc).  The need to introduce the -1 suggests to me that we're excluding the photo which has no children in it.


I had not expected a logarithmic series from this starting point; in fact I had not expected expected the number of photographs to increase so quickly - the volume more than doubles each time, as we have to account for every combination incorporating the new child. I was expecting something similar to a Fibonacci series - but that's more about multiplying rabbits, not children!



Monday, 29 February 2016

BODMAS puzzles - what's the fuss?

There's a phase going round Facebook where unsolvable, convoluted maths problems are doing the rounds: The question starts: "93% give the wrong answer, only a genius can solve this."  And there's usually a picture of Albert Einstein. And then there's a maths question  - they vary in length but have the same general shape: single-digit numbers separated by various maths functions.

3×4+1-3+4 = ?

You don't have to be a genius, you just need to understand the rules of maths grammar.

And, since this has been shared on Facebook, you'll also gave to explain clearly why your answer is correct in the face increasing ire.

All the best with that.

Saturday, 30 January 2016

Back to the Future: DeLorean Acceleration Rates

Towards the end of the film Back to the Future, Marty McFly has to accelerate the DeLorean time machine up to 88 mph in order to travel from 1955 to 1985.  

Doc Brown explains: "I've painted a white line waaayyy over there on the street. That's where you start out. I've calculated the distance and wind resistance to active the moment the lightning strikes. This alarm will go off and you hit the gas..."


Simple question:  how far away was the start line from the electric overhead wire and the clock tower?

We can use simple dynamics (or kinematics) to calculate the distance the the DeLorean would have needed to reach 88 mph, if we know the car's rate of acceleration, and take it as a given that the car is starting from rest (it's stationary).


The formula to use is v2 = u2 + 2as where v is the final velocity (88 mph), u is the start velocity (0 mph), a is the rate of acceleration, and s is the distance (which is what we want to know).

Inserting u=0 and rearranging, we have s = v2 / 2a.

According to the Wikipedia entry for the DeLorean, acceleration from 0-60 mph took 8.8 seconds.  And this is where it gets tricky, because s = v2/2a requires consistent units for time in the velocity and acceleration.  I am going to make the simplifying assumption that the acceleration from 0-60 continues from 60-88 mph. In reality, it doesn't, but we'll assume it does.

60 mph = 60 / (60 × 60) miles per second = 0.01666 miles per second.

To reach this speed in 8.8 seconds, the acceleration rate is 0.01666 / 8.8 = 1.8939 ×10-4 miles per second per second. 

88 mph = 88/ (60×60) miles per second = 0.02444 miles per second. 

Time to plug in the numbers:

s= (0.02444) 2 / (2× 1.8939 ×10-4)

s = 1.572 miles

And, just for interest, how long (seconds) would it take? That's easier, using v=u+at and solving for t: t = v/a = 88/8.8 = 10 seconds.

So, the Start Line was just over a mile and a half from the clock tower, (perhaps you could describe that as "waaay over there" with some dramatic licence)  and the journey would have taken 10 seconds (all assumptions taken into consideration).  Somehow, though, it seems a little bit longer on screen.

Some other 'everyday maths' articles I've written:

A spreadsheet solution - the nearest point to the Red Arrows' flightpath from my house
The Twelve Days of Christmas - summing triangle and square numbers
Why are manhole lids usually circular?



Thursday, 17 December 2015

Should Chelsea Sack Jose Mourinho?

In previous posts, during previous football seasons, I've monitored the performance of certain football managers - in particular David Moyes and Louis Van Gaal.  I'm not really targeting Manchester United specifically, it's just that over recent seasons, they've had a tough time and there's been some speculation about their managers' futures.  In fact, Moyes was sacked before his first season was finished.

This season, Chelsea's Jose Mourinho is coming under scrutiny.  At the time of writing (16 December 2015) his team have played 16 games and are in 16th place (out of 20) and sliding towards the relegation zone.  But is the situation really that bad?  It's time to compare his performance against some of the others I've mentioned.  The first comparison is cumulative points achieved through the season, and I'm comparing Mourinho with Moyes (his line is the 'this performance will get you fired' line).

Looking at this, it would appear that Mourinho is not going to last until the end of the season.  There's clearly more going on here - for example, Moyes was in his first season after Ferguson's era of success, while Mourinho is continuing after winning the league title last season.  And perhaps Chelsea (the club, staff and fans) are more loyal to their manager.

So, assuming that Mourinho is going to stay in place, at least for the short term, then let's look at what's going wrong for him (I guess he'll be more aware of this than me, but let's look impartially at the stats).

First of all: the performance during the first ten games of the season:


There's nothing obviously wrong with the number of goals his team is scoring: the problem is with the number being conceded.  Chelsea used to be famous for 'parking the bus' (i.e. scoring a goal and then defending with complete success) but it now appears that they've got a very leaky defence - and too leaky to be a serious challenger for the top position.
  If we compare their current position (after 16 games) with some of the other teams in the league, we find some interesting points:

1. Only two teams - the bottom two, Aston Villa and Sunderland - have lost more games than Chelsea (Chelsea = 9, Sunderland = 10, Aston Villa = 12).  Previous analysis of Moyes and LVG in particular indicated that they were drawing too many matches that they needed to conver to wins.  Mourinho's task is different - it's not stop drawing, it's
to recover more draws from losing situations and to stop losing
Comparison of Jose Mourinho to Alex Ferguson's
first season; final season; David Moyes
and Louis Van Gaal.

As at 16 December, the win/lose/draw rate for the Premier League, sorted by league position
from left to right.  Note the high lose-rate for Chelsea.


2. After 16 games, Chelsea have four clean sheets, ranking them joint 11th, mid-table.  Their issue is not the number of clean sheets they're keeping, it's conceding more goals than they're scoring (I know that seems obvious, but they don't have to keep clean sheets to help them improve their position).


3.  Chelsea's goal difference is not a significant factor. Or, to put it another way: on average, they're not losing by huge margins in their games.  The recommendation based on this (and their significant lose-rate) is to play more aggressively and play less cautiously when they concede a goal.  They can afford to lose by 3 or 4 goals without significantly denting their goal difference compared to the teams around them.



So, should Chelsea sack Mourinho?  Maybe, although perhaps he can be relied upon to change his team's style and go for a more attacking style - he has goals to play with, if not games.

More articles on data analysis in football:

Reviewing Manchester United's Performance
Should Chelsea Sack Jose Mourinho? (it was relevant at the time I wrote it)
How exciting is the English Premier League?  (quantifying a qualitative metric)
The Rollarama World Football Dice Game (a study in probability)

Thursday, 10 December 2015

The Mathematics of Post Office Queues

I'm sure there's probably plenty of research (anecdotal, serious, genuine and some of it even humorous) around standing and waiting in queues.  Queuing is the stereotypical British national pastime, and we seem to be quite good at it.  However, if you think that being good at it means that we enjoy it, then you're mistaken.  In my own personal opinion, the worst place to queue is at a local Post Office, and as we approach Christmas and I send out parcels and so on, I'm getting to experience more of it.  Enough of it, in fact, to have done some empirical and informal research of my own.

Firstly, let's look at some assumptions about good customer service in a queue situation:

1.  If the queue gets longer, then introduce more staff to the counters.  Or, in mathematical terms, the number of people on the counters should rise in direct relation to the number of people queuing.  Not a one-to-one relationship (one assistant per customer would be expensive to staff and lead to very wide checkouts), but that there should be a consistent rise in assistants as the queue gets longer.  This continues until, of course, the desks are fully staffed and there's no more capacity.

1b.  If the queue gets longer, then the number of staff visible doing non-customer-facing administration tasks behind the desk should decrease.  There really is nothing more infuriating than a member of staff, who could be serving customers, is clearly visible doing something mundane like counting stamps.  Seriously.

2.  Consequently, if the queue gets shorter, it's reasonable to reduce the number of assistants on the counters.

3.  If the queue gets longer, then more effort should be spent to reduce the amount of time it takes to serve each customer.  Keep things formal, keep things concise and keep the queue moving.  The amount of time spent per customer should be inversely proportional to the length of the queue.

Let's have a look at graphical representations of the ideal situations outlined above:

1.The number of assistants increases as queue length increases.  There are two lines plotted on these graphs:  one (the blue line) for a larger office where more staff are employed, and another (the pink line) where there are fewer staff employed.  The principle is the same.


2.  As queue length increases, the number of staff doing non-customer facing work decreases.  Again, there are the two lines, with the pink link showing a smaller office.



3. Amount of time spent on each customer decreases with length of customer.  For smaller branches, the amount of time spent needs to fall more quickly as there are fewer assistants to handle the queue.  One interpretation from the graph shown below (which is a purely illustrative graph, with arbitrary numbers) is that as the queue length increases from 1 to 10 people, the amount of time that should be spent on each customer should fall from around five minutes to one minute.


Now let's look at what can happen when this breaks down.


1.  Increasing the number of staff on the desks when the queue length increases
Really?  More staff?  They're on their lunch break.  They're on training.  Or...
1b.  ...worse still, they're sitting at their desk counting out money, just behind a 'position closed' sign.  They're moving around behind the other assistants, putting paper into drawers and rearranging posters; fetching and distributing their business cards.  Infuriatingly visible to the ever-lengthening queue, and incomprehensibly not serving any of the people in it.


3.  There are some questions, such as, "Do you have a landline at home?" and "Do you know when your buildings and contents insurance is due for renewal?" and "Did you know that we offer travel insurance?" that are understandable when the queue is relatively short.  After all, the desks are well-staffed, people haven't been waiting for very long and there is potential for these up-sell opportunities.  However, when the queue is long, and has been long for many minutes, and when there are only one or two assistants at the desks, these questions really aren't helpful.  


As an additional consequence:  the likelihood of a potential up-sell falls sharply as the queue length increases.  People who've been waiting in the queue for ten minutes to do a three-minute job don't have the time to book an appointment to change their broadband provider.

Here's how I picture the graph of actual time spent per customer, and how it varies with queue length.  This is for the larger office I imagined above, but again, the principles are the same for smaller and larger outlets.


What happens here is that customers actually take it upon themselves to reduce the amount of time it takes to complete their task.  Having spent so long in a queue, they now wish to move through the execution of the task more quickly.  They dispense with formalities about the weather; the time of year; their plans for the weekend, and become much more focused on their task.  They have their money ready.  They have a pen in their hand, if needed.  Out of a sense of camaraderie with their fellow queuers, they aim to get served as quickly as possible, to alleviate any further unnecessary waiting for their fellow man. Moreover, they instinctively decline any offer of discounted insurance or other special deals.

And the consequence?  Here's the related 'probability of successful up-sell' versus queue length graph.


You'll notice that the graph actually falls below zero as the queue length extends beyond around 23 people.  This seems very strange - after all, there can't be less than a 0% chance of something happening.  What happens here is that the negative effect of standing in a queue with that many people in it is that people start to tell their friends about their queuing experience, and this negatively skews any future up-sell opportunities too.  Here, then, is perhaps a more sensible approach to how to make up-sell overtures.

But seriously...

Okay, so perhaps I'm being a little obtuse.  But you get the idea.  The Royal Mail is under threat from smaller couriers and delivery providers, but it has the advantage of a large branch network and brand familiarity.  We go to the Post Office because our parents did, and we know how the delivery system works.  However, the Post Office finds itself having to diversify into various financial products to keep itself profitable.

My worry is that this diversification is detracting from their core customer experience:  I know I've potentially exaggerated how frustrating queuing can be, but it seems to me that Post Office employees are not aware of this and continue to blanket-bomb everybody with the same sales lines, which are increasingly frustrating.  As more couriers become available online, and they continue to become more efficient, building relationships with other high-street stores (Argos is an example), I strongly suspect that more people will turn to them for their delivery needs.  At our house, I would estimate that 30-40% of the parcels we receive come via Hermes, but there's also DPD, parcel2go or Interlink.

So, Royal Mail have the history and the branch network, and the face-to-face engagement with their customers.  I just wonder how long it will last.

In fact, it seems that this is an ongoing problem.  And it's been going on for years!  During my search for a cartoon to add to my article (I borrowed the one just above from the Daily Mail, I found this article which lists everything I've said:  
Our too-pushy post offices: Customers forced to queue for too long before being offered services they don’t want. There are some alarming stats in there (and this is three years ago):

- One post office user in three has to queue for at least five minutes, and for some the wait is more than twice that long said Consumer Focus (then Consumer Futures, now Citizen's Advice), which tested 448 post offices in urban high streets.

- For many customers, who are used to supermarkets opening extra tills if queues develop, the small number of counters which are open is exasperating.
- For example, Consumer Futures said a typical Crown office has 7.3 counters, but only 3.8 are actually open.

(And, while I think about it:  everything I've mentioned here applies just as equally to the high street banks.  The queues; the number of assistants at desks; the number of staff walking around not-quite-so-behind-the scenes, and of course the blanket approach to upselling financial products.  Why do you think I bank online?)

Some other 'everyday maths' articles I've written:

A spreadsheet solution - the nearest point to the Red Arrows' flightpath from my house
The Twelve Days of Christmas - summing triangle and square numbers
Why are manhole lids usually circular?

Monday, 30 November 2015

Don't Make Me Think = Don't Make Me Read?

We all know (because we've all been told) that online selling must follow the eternal (pre 1990) mantra that 'less is more'.  Less clutter, less text and less mess means less confusion equals more clarity equals more sales.  Yet in the offline world, shop shelves are stacked with 23 different brands of toothpaste, 32 different types of shampoo, and aisles and aisles of goods.  And if you think the bricks-and-mortar model is dead, and you'd prefer a modern comparison:  why are Amazon's warehouse shelves so full of so many different types of identical products?  And why do they have so many web pages?


Ignoring that argument, we know less is more because if there's "more" then people will have to think about the product they're buying. And we know thinking is bad because there's a book about online usability called "Don't make me think," and in this era of online publishing and blogging, you must surely be a respected authority on a subject if you can get a book published.  We may not have read your book, but we've heard of it, and we know the title.  [Steve Krug is a respected authority, and was even before he wrote his book].

But could you imagine if this less-is-more attitude was taken a step further in the offline world?


Imagine going to a bricks-and-mortar store, reaching the checkout with your selection, and then making eye contact with the checkout assistant. He (or she) looks away, grabs your shopping off you; scans the barcodes and runs up the total, then looks at you. You look back. He points to the total displayed on the cash register. You reach for your credit card. He waves his hand towards the card machine.


You put your card in the machine. He does whatever it is they do on the cash register to make the magical words “Enter your PIN” appear. There’s brief delay, the words “Transaction approved” appear in black on green on the dot-matrix screen, the assistant hands you your receipt and without any further delay turns to face the next customer.

Delightful, isn’t it? After all, you bought your items and paid for it successfully, didn’t you?  And did you have to think?  Perhaps you would have preferred to use one of those self-service checkouts, complete with 'unexpected item in the bagging area'.

This is the epitome of decluttered pages, where removing anything and everything that isn’t part of the main purchase experience is the absolute aim and surely conversion improvements will follow.  As online analysts, we've trained our managers and superiors to think that less is more, that clutter is bad and that we should just get people to press the button and buy the stuff. However, I believe that kind of thinking is out-of-date and needs to be revisited.

Our visitors are intelligent people.  They are not all high-speed 'I'd buy this even quicker if you got out of my way' purchasers.  Some of them actually want to read about your product - its unique selling point, its benefits, why it's not the cheapest product you offer.  They want to view the specifications (Is it waterproof?  Is it dishwasher safe?) and they won't buy the product unless you reassure them that it's the one they want.  We can reduce our product specifications to icons (yes, it's ultra secure, and it's got central locking and built-in satnav) but if your icon isn't either well-known or intuitive, then you made things worse by removing the words "with a built-in satnav" and replacing them with a picture of ... well... a wifi point?  Have we have started to think (subconsciously) that we should just show glossy pictures of our products and that this would be enough?
 


Is text bad?  And is more text worse?  I don't think so - after all, you're reading this, and despite my best efforts, it's pretty text-heavy with only a couple of images thrown in to break up all these words.  I'm making some pretty heavy demands on you (to read this much text, paragraphed but largely unformatted), but you've stuck with me this far.  I know online selling is different from online reading, but if you've managed to read this much, then it's fair to assume you can read some sales copy on a web page for a product that you are genuinely interested in.

So, is less more?  I am calling for a more balanced approach towards website content. We need to understand that it isn't simply about "less" and "more".  It's about the right content in the right place, at the right time to support a visitor's intentions (which may be 'to buy the product' or may be 'to find the best one for me'.)  And having said this much, I'll stop.





Friday, 23 October 2015

Numbers 1,2,3,4,5 - 101 to 200

After recent posts, here's the second instalment of 'produce each number from 1 to 200 using 1,2,3,4,5 and basic maths functions'.  Here's the second half - from 101 to 200.

101 = (53*2) + (1+4)
102 = 51 * 2 * (4-3)
103 = 123 - (4 * 5)
104 = (25 * 4) + 1 + 3
105 = (4+3) * (2+1) * 5
106 = (54 * 2) - (3-1)
107 = (13 * 5) + 42
108 = (5^3 - 21) + 4
109 = 134 - 25
110 = (53 * 2) + (4*1)
111 = 135 - 24
112 = 132 - (4*5)
113 = (41 * 3) - (5*2)
114 = (54 + 3) * 2 * 1
115 = ((3 * 4 * 2) -1) *5
116 = (23 + 5 +1) *4
117 = (24 * 5) - (3*1)
118 = 125 - (3+4)
119 = 23 * 5 + (4 * 1)
120 = 1 * 2 * 3 * 4 * 5
121 = (2 * 3 * 4 * 5) + 1
122 = 154 -32
123 = 123 * (5 - 4)
124 = 134 - (2 * 5)
125 = (4^(5-1) / 2) - 3
126 = 125 + (4-3)
127 = 1 * 5^3 + (4-2)
128 = (35 * 4) - 12
129 = 153 - 24
130 = 5^3 + 4 + (2-1)
131 = (25 * 4) + 31
132 = (3! * 15) + 42
133 = (45 * 3) - (1 * 2)
134 = (2 * 5 * 13) + 4
135 = (45 * 3) * (2-1)
136 = ((45 + 1) * 3) -2
137 = (35 * 4) - (1 +2)
138 = (4^3 + 5) * 1 * 2
139 = 4! * 3! - (5 * (2-1))
140 = ((45 + 2) * 3) -1
141 = 135 + 4 + 2
142 = (52 * 3) - 14
143 = 135 +  (4 * 2)
144 = 142 + (5-3)
145 = 152 - (4 + 3)
146 = (4! * 3!) + 5 - (1+2)
147 = 153 - (4 + 2)
148 = (35 + 2) * 1 * 4
149 = (12 * 3 * 4) + 5
150 = 15 * (4 + (3*2))
151 = 145 + (3 * 2)
152 = (3^4 - 5) * 1 * 2
153 = (53 - 2) * (4-1) = 1! + 2! + 3! + 4! + 5!
154 = (5! + 34) * (2-1)
155 = 153 + (4-2)
156 = 1 * 4! * (5 + 3/2)
157 = (31 * 5) + (4/2)
158 = (2 * 3^4) - (5-1)
159 = 213 - 54
160 = 154 + (3 * 2)
161 = 153 + (4 * 2)
162 = 54 * 3 * (2-1)
163 = ((51 + 4) * 3) - 2
164 = 152 +  (4 * 3)
165 = (34 + (2-1)) * 5
166 = 5^3 + (42 -1)
167 = (34 * 5) + (1 * 2)
168 = 213 - 45
169 = 13^2 * (5-4)
170 = (4! * (5+2)) +  (3-1)
171 = (51 +2 + 4) * 3
172 = (45 -2) * (3 +1)
173 = (34 * 5) + 1 + 2
174 = 4! * 5 * (2-1)
175 = (3+4) * 25 * 1
176 = ((5! * 3/2) - 4) * 1
177 = 153 + 24
178 = 5! + (1 + 4!) * 2) + 3
179 = (3^2 * 4 * 5) -1
180 = 5 * 4 * 3^2 * 1
181 = (5 * 4 * 3^2) + 1
182 = 152 + 3! + 4!
183 = (54 * 3) + 21
184 = (5! * 3/2) + (4*1)
185 = 5! + 4^3 + (2-1)
186 = (5! + 4) * 3/2 * 1
187 = ((4^3) * (2+1)) - 5
188 = (32 * (5+1)) -4
189 = 31.5 * (4+2)
190 = (4! * (5+3)) - (1*2)
191 = (5 * 34) + 21
192 = 24 * (5+3) * 1
193 = 4! * (5*3) + 1
194 = (43 * 5) - 21
195 = (51 * 4) - 3^2
196 = (4 + 3)^2 * (5-1)
197 = ((52 -3) * 4) - 1
198 = (51 * 4) - (3*2)
199 = (51 * 4) - (3+2)
200 = (1 + 3 +4) * 25

I posted my results for 1-100 and my intention to post 101-200 on the freemathhelp forum (which I strongly recommend for any maths or logic problem or puzzle), along with a challenge to improve my answers with more elegant ones.  For example, using only basic maths function (no powers), and possibly answers which use the digits 1,2,3,4,5 in order.  One of the regular contributors there, Denis, took up my challenge and has produced solutions for 1-200 using the digits in correct order.  I had enough difficulty doing this with the digits in any order (occasionally stumbling on elegant solutions), but he's got the full set.  He's kindly shared his full solution with me, and permitted me to share it (after all, that's what problem solvers do), and that will be next time.