Posted by: dhaleyjr | October 6, 2008

## 1 out of 1000: A Probability Riddle

So no CS topics this time. Instead I wanted to share a probability problem that I heard a while ago that I enjoyed. It’s a hedge fund logic puzzle, similar to many questions you might expect in those sorts of interviews. Since you’re supposed to be thinking on the spot in an interview, the problem is not necessarily difficult as long as you view it the right way. I’ll post the question and put up the answer significantly below it.

#### Question

Suppose you have a jar with 1000 pennies in it. You are told that one of the pennies is double-headed, while the rest are normal. You choose 1 penny and flip it 10 times in a row… and get 10 heads. After lamenting that you didn’t buy a lottery ticket instead wasting your luck on a penny flipping game, you try to determine the odds that you chose the double-headed coin. Don’t ask why you can’t just look at the other side of the coin and determine with 100% certainty if it’s normal because i’ll tell you now: right after you flipped and saw the tenth head, all the coins disappeared, leaving you nothing but this problem to solve. So what is the probability you chose the double-headed coin?

#### Filler

The explanation comes now, so if you don’t want to know what the answer is, don’t read this. Consider yourself warned (twice if you, for no reason at all, read the filler section).

There are 2 events to consider. First, what is the probability that you flip a normal coin 10 times in a row and get heads every time. Since you have a 1/2 chance on each flip and there are 10 flips you have 1/(2^10) or 1/1024 chance of this. Good luck ever getting that to work. The odds that you picked a normal coin from the jar are 999/1000, or approximately 1. So the total probabiltiy of choosing and flipping a normal coin heads 10 times in a row is approximately 1/1024.

The second event is that you chose the double-headed coin and flipped it heads 10 times in a row. Now, given that you have the double headed coin, the probability of getting heads on ten consecutive flips is 1. (We’re going to discount any probability of landing on its side or being grabbed mid-flip by a bird and not landing at all). So the probability of choosing the double-headed coin and flipping it 10 heads in a row = the probability of choosing it. This is simply 1/1000.

So the odds for the normal coin are approximately 1/1024 and for the double-headed is 1/1000. Though not quite equal, they approximately the same meaning the odds you chose the double-headed coin is approximately 50/50 or probability of .5.

And now an unrelated joke…. recently we had some fruit fly problems in our room. So while looking for solutions, my roommate stumbled upon the following phrase:

Time flies like an arrow,  fruit flies like a banana.

Think about it… haha it cracked me up.