Monday, March 25, 2013

Matters of Size

Someone with more resources than me has tackled a problem related to the subject of an earlier post about Tim Hortons' Roll Up the Rim contest.  Do the odds of success increase with cup size?

The analysis done by the authors is incomplete, in my opinion.  The findings of their experiment are consistent with popular suspicions.  The largest cup has the highest success rate.  The smallest cup has the lowest success rate.  The two middle sizes have a success rate of exactly 1 in 6.  So success is roughly ordered in terms of cup sizes.  Does their experiment actually prove that the game is rigged in favour of larger cups, though?

This is after all a relatively small number of cups.  There are millions of cups distributed during the contest, but they didn't even check 100.  How well does the data on this particular sample reflect the distribution of cups across the country (and the small portion of the US with Tim Hortons)?

Again, as in my earlier post, we can consider the likelihood that one of these would actually happen.  If something extremely unlikely happened, it's fair to accuse Tim Hortons of skulduggery (something we should do as often as we can, if only because of the greatness of the word).  If we can expect these events to happen fairly often, we should reserve our judgment.

How likely is it, then, for you to win only 4 times in 38 tries, as in the case of the small cups in the article?  Without getting into details, that number is 11.6% (rounded to 1 decimal place).  Compare this with the 1/6=16.7% chance of winning on a single cup.  So your chance of winning on a single cup is only about 50% greater than winning only 4 times out of 38.  You're on the wrong side of the odds, but not so far that it proves the likelihood of conspiracy.  Roughly 1 in 10 people will have the same experience as you.

What about at the upper end?  What is the probability that you would win 5 times with a mere 18 cups?  10.3%.  This is also close to 1 in 10, nearly the same probability as winning only 4 times in 38 tries.  Again, it's not an extremely unlikely event, and not enough to prove foul play.

My own analysis, of course, is not sufficient to prove that there is no conspiracy either.  My only complaint here is that nor is the Huffington Post's analysis sufficient to prove that there is.  Unfortunately, in my opinion, the manner in which their findings were presented might serve to suggest that they have proven the popular perception.

There are better ways of discerning how reliable our inferences from Huffington Post data are.  This is where my expertise runs out.  The math professors in the article might have been more knowledgeable.  If they weren't, one of them most certainly could have found someone who was.  It's a shame that this wasn't done, or if it was done, that it was left out.  It may leave the readers with the wrong impression.

One of the main responsibilities of the media, whether print or electronic, should be to properly inform the public.  In my opinion, the Huffington Post only did half a job in that regard, and in this case, to the extent that the odds winning free stuff from a coffee cup matters, it might be worse than doing nothing at all.


As an addendum, we could ask why it would be wrong if large sizes gave more prizes.  Presumably people object on the grounds of fairness.  But is it fair to give the same odds of winning to people who pay more for a higher price for their extra large as the people who pay the lower price for a small, especially when you know that if people win a free coffee off the small, they're likely to opt for a larger size when they collect than what they would normally get?  In what other context would we think it fair for someone who paid more to have the same chance of winning?

For public relations reasons, Tim Horton's is probably right to make it even.  But I think they'd be justified if it weren't, as long as they only adjusted the odds to compensate for the different prices paid.

Saturday, March 23, 2013

The Price of Good Parenting

I saw Kinder eggs at the grocery store the other day.  I see them every week, actually, but the ones I saw last week stood out because they came in a box of three and had a Hot Wheels label on it (Hot Wheels being one of my favourite childhood toys).  The printing on the box explained that there are six different Hot Wheels toys in and each box of three Kinder eggs contains exactly one with a hot wheels toy in it.  Kinder obviously wants you to collect all 6, and just in case you weren't sure of that, it also says "collect all 6" on the box.

Suppose you set out to collect them all (or rather, your child convinced you to let him set out to collect all 6).   How many boxes would you have to buy, on average, before you collected all 6?

Before we answer this question, let's consider a different question.  What is the probability of getting all 6 different cars in the first 6 boxes?  To figure this out, we need to know two things, the number of different ways of getting all 6 in 6 boxes and the number of possible outcomes from getting 6 copies of the exact same car to getting all 6 different cars.  Dividing the first number by the second gives the probability.

Let's assume that you open the boxes one at a time and that the cars are distributed evenly across the boxes.  Suppose that the different cars are numbered 1 to 6 and that as you open the car-containing kinder egg, you write down the number of the car.

If you win all 6 in the first 6, then you have written down the numbers 1 through 6 in some order.  How many different ways are there for this to happen?  Well, there are 6 possibilities for the first number you write down.  Having written down one number already, there are only 5 possibilities for the second number.  Similarly, there are only 4 for the third number, 3 for the fourth, 2 for the fifth and 1 for the 6th.  If we multiply these numbers together, we get the total number of ways that we could win 6 cars.  So the number of ways to win is 6 x 5 x 4 x 3 x 2 x 1 = 720 ways.

Now let's consider the total number of possible outcomes, whether or not you got all 6.  There are 6 possibilities for the first box, 6 for the second box, and so forth.  To get the total number, then, we just multiply 6 by itself 6 times (or, equivalently, take 6 to the power of 6), to get 6 x 6 x 6 x 6 x 6 x 6 = 46656 possibilities.

The probability of getting all 6 cars in the first 6 boxes is then 720/46656=0.01543=1.5%.  Those are better odds than Lotto 6/49, but still not very high.  That doesn't help us answer the question of how many boxes you will have to buy, but it does tell us that you most likely will not have all 6 cars from your first six boxes and so  you will have to buy more.

Since the cars are distributed evenly across the boxes, the probability of getting any one car is 1 in 6. Thus, if you have already won k cars, then the chance of getting a car you already have in the next box is k/6 and the chance of getting a car you don't have is (6-k)/6. 

To determine the average number of boxes needed, we'll start from the end, assuming you only need one more car to complete the set, and work backwards to the case where you only have one car.

If you have already got 5 cars, then there is a 5 in 6 chance that complete the set and 1 in 6 chance that you have to buy another box.  This is essentially the same situation is the Roll Up the Rim where there is a 5 in 6 chance of losing and a 1 in 6 chance of winning.  There, we concluded that it took an average of 6 tries before the first win.  Using the same argument, we conclude that it will take an average of 6 more boxes before getting that last car to complete the set.

If you've got 4, there is a 4 in 6 chance of getting one you already have and 2 in six chance of getting one you don't.  By the same reasoning we used above for when you have 5, we can argue that it will take an average of 6/2=3 more boxes before you get the next new car.  Then, according to the previous paragraph, it will take 6 more boxes until the set is complete.  Thus, if you have 4 cars, it will take an average of 3+6=9 more boxes to complete the set.

Similar arguments can be used if you've got 3, 2, or 1 distinct cars, the only difference being in the probabilities of finding a car you have already or one you don't.  If you add up all the numbers from each case, you get 14.7.  This is the average number of boxes you need to buy before you get all 6 cars, answering the original question.

Each box costs $3.49.  So on average, you are spending 14.7 x $3.49=$51.3.  If you are in Ontario, you are paying 13% tax, so the total cost would be $57.97.  You are probably better off if you just go out and buy a set of 6 Hot Wheels and a chocolate bar.  Both the the cars and the chocolate will be higher quality, and you don't have to worry about dealing with kids who are hopped up on the sugar from 44 Kinder Eggs.

Thursday, March 14, 2013

Progress to Keys

A friend of mine once told me this joke.  A woman was cooking a ham.  Before she put it in the pan, she cut off the ends.  She had always done it that way.  Her husband noticed and asked why she had always done this.  She had no reason other than that's what her mother did.  So she called up her mother and asked why.  She didn't know either, because she simply copied the practice from her own mother.  So she called up her grandma who explained that she only did that because her pan was too small.

I thought of this joke one day not too long ago when I looked down at my keyboard and noticed how the keys on the keyboard were arranged, not the letters on the keys, but the actual physical keys.  I've seen keyboards almost every day for a long time, but I never noticed the oddness of the layout.  First of all, they are arranged on a downward slant, going left to right.  Secondly, the slant is only sort of a slant.  The offset between the keys in the home row (the middle row of letter keys) and the keys in the row above it is greater than the offsets between the keys in the top two rows and between the keys in the bottom two rows.  Why this asymmetry?  Why the inconsistent offset?

There must be an ergonomic reason for the odd, asymmetrical arrangement, right?

If you learned touch typing you were taught to have your fingers resting on the home row, with the fingers on your left hand occupying the a, s, d, and f keys and the fingers on the right hand occupying the j,k,l, and semi-colon keys.  Each finger is responsible for the keys in the slanted column containing the key on which it rests, with the index fingers doing double duty as they cover the columns between the f and j keys.

Because of the slant, I find that the index finger on my left hand rubs slightly against the middle finger, while on my right hand the index finger is drawn away from the middle finger.  At least it does if I follow the instructions of my typing teacher (do they still have those?  I would guess not.).  I also find that because of the slope, the Q is easier to type than the P, even though they are reflections of each other across the centre of the keyboard, both typed with the pinkie finger on the key above their "home" key.

I guess it's win-some/lose-some, with some stuff easier on one hand and other stuff easier on the other hand.  But it would be hard to believe that this was intentional, especially if you consider that P occurs more frequently than Q in a typical English text.  If it had been done intentionally, the designers would have reversed the two letters (assuming it had been decided that both were to be typed with the pinkie on the row above the home row).

 Of course, it wasn't done intentionally.  This is where the ham comes in.  The modern electronic computer keyboard was based on the old fashioned mechanical typewriter.  We had a couple of these in the house when I was growing up, before the advent of the affordable desktop computers, and long before brand new laptops could be had for less than a fifth of a graduate student's monthly salary.  I'm sure electric typewriters had been invented by that time, but those were for people in higher echelons of society than ours.

On these old mechanical non-eletronic beasts, the keys were attached to long metal arms.  Arms attached to keys in the same column were placed as closely to each other as possible, but obviously could not occupy the same space.  This forced the arrangement of the keys at the time, and that old arrangement is roughly the one that we use to this day.  Despite the fact that it has not been necessary for a long time, the oddly offset, asymmetrical arrangement still persists.

It survived electronic typewriters and computer  keyboards.  It survived the jostling of key positions in order to fit the most important keys of a typical computer keyboard into the constrained spaces of laptop computers.   Perhaps most surprisingly, it survived various attempts by aftermarket computer keyboard manufacturers to sell keyboards that were more ergonomic.  The keyboard was rounded to better fit the shape of the hand.  The left and right hand sides were severed from each other and laid out in an attempt to produce a more natural angle.  Yet, like cutting the ends off of the ham in the joke, the downward slant and irregular offset remained through all of these changes.  One would think that at some point, those people who were tinkering with other aspects would have noticed this and realized there was no point to it.

With the dawn of tablets and smart phones, whose space constraints are even tighter than laptops, some keyboard designers finally have been forced to quit old habit.  Touch screen keyboards are mostly grid-like, and smart phones with qwerty keyboards tend to arrange their keys without slant or offset.  This practice does not seem to have influenced makers of full sized keyboards yet.

Of course, this is probably not a huge issue.  After all, it took me more than 20 years of typing before I even noticed.  But still, given that it's not necessary to type this way, given that it doesn't treat both hands equally, I think it would make some sense if we had something more... even handed to type on.


Although it is less significant, the legacy of the mechanical keyboards reminds me of this.