Wednesday, September 23, 2009

A flipping fortune

You begin flipping a coin. Each time it comes up heads you double your money . You stop when the coin lands tails up. How much money do you expect to make before you throw a tails? You start with $1. I've no idea where the money is coming from.


Addendum, 10/10/09. The expected value is the same as the average value. To measure it, you would have to observe an infinite number of trials.

You cannot lose in this game. If you threw 10 heads, then a tail, you'd walk away with $1024. The probability of doing that is 1/2048. If you threw a tail on your first flip, you'd still have $1. The probability of doing that is 1/2.

Labels: ,

38 Comments:

Blogger Ragknot said...

(1) Half the time, you would end on the first toss.
(2) The other half of the time, you would double your money... then return to step 1, for a second chance.

September 23, 2009 6:20 PM  
Blogger Chris said...

HI Ragknot. I've updated the hourglass.

I'd love you to simulate this one. I'm not sure if you've deliberately failed to complete the reasoning (or not).

September 23, 2009 6:57 PM  
Blogger singh said...

i dont get this.........

September 23, 2009 8:39 PM  
Blogger Chris said...

Hi singh. I'm not quite ready to give any clues yet. I will do so if everyone seems to be stuck. I usually post the solution within 24-48 hours of posting the problem.

If you meant that you don't understand what the problem is saying, say so, I'll see if I can make it clearer.

September 23, 2009 9:03 PM  
Blogger Ragknot said...

Chris,
I could simulate this, but I fail to see the point. The chance is 50/50 to get a heads. There's a slim chance you could win a lot, but it would be much more likely not to.

Is there something I missed?

September 23, 2009 9:35 PM  
Blogger Knightmare said...

this is simple!
if you keep doubling down-sooner or later the coin will come up tails and you will loss.your chances of winnig anything are zero (in the long run).

September 23, 2009 9:52 PM  
Blogger Ragknot said...

I simulated about 200 times with about 65,536 flips for each run.
Once I got a max of $32768, which means about 15 heads in a row.
Most of the time the max out of 65536 flips was $64 to $512.

Here's a short run that had $2048.
(12 wins in a row)

Start --------------- $1
Tails ...Begin…... $1
Heads ...WIN…….. $2
Tails ...Begin…... $1
Heads ...WIN…….. $2
Heads ...WIN…….. $4
Tails ...Begin…... $1
Heads ...WIN…….. $2
Heads ...WIN…….. $4
Heads ...WIN…….. $8
Tails ...Begin…... $1
Tails ...Begin…... $1
Heads ...WIN…….. $2
Heads ...WIN…….. $4
Tails ...Begin…... $1
Tails ...Begin…... $1
Tails ...Begin…... $1
Tails ...Begin…... $1
Heads ...WIN…….. $2
Heads ...WIN…….. $4
Tails ...Begin…... $1
Tails ...Begin…... $1
Tails ...Begin…... $1
Tails ...Begin…... $1
Tails ...Begin…... $1
Heads ...WIN…….. $2
Tails ...Begin…... $1
Tails ...Begin…... $1
Tails ...Begin…... $1
Heads ...WIN…….. $2
Heads ...WIN…….. $4
Heads ...WIN…….. $8
Heads ...WIN…….. $16
Heads ...WIN…….. $32
Heads ...WIN…….. $64
Heads ...WIN…….. $128
Heads ...WIN…….. $256
Heads ...WIN…….. $512
Heads ...WIN…….. $1,024
Heads ...WIN…….. $2,048

September 23, 2009 10:08 PM  
Anonymous t..:B::H said...

you go from probability to a "sure"
statement when you say "I expect xx Dollar". Don't like that, it's not that simple.

But what I would expect is to win 2^(6Billion-1) Dollars, since i am THE person on this world who will pick the statistically max out of all coin-throwing people on the planet...

September 24, 2009 12:21 AM  
Blogger quantense said...

Hi Chris. If we through N times, probability of all heads
is 1/2^N. In this case you got 2^N dollars. Average is summ. over all N dollars*prob. When you got tail before N the number of dollars is zero, and therefore corresponding term in sum. is zero. Otherwise the number of dollars is N+1, when you through coin N times.

September 24, 2009 4:24 AM  
Blogger Chris said...

Hi Knightmare - you don't lose when tails is thrown. Tails simply ends the process.

Ragknot. Thanks for the simulated runs. I really don't know if doing 1000s of runs will give a clue (that's a clue).

All, the key word in this probability problem is "expect". Ragknot and t:b:H have provided very helpful information, although that isn't stunningly obvious.

September 24, 2009 4:25 AM  
Blogger Chris said...

Hi quantense. Our posts crossed. You're the closest in the reasoning. Read my response to the others. I expect ;) you'll crack it off then. Be a little more careful about what the probability of N heads is - although that won't affect the solution.

All. Notice that I've been brave enough to label this as a "trick of mind" problem.

September 24, 2009 4:36 AM  
Anonymous t::b...H: said...

yeah, quantese got it pretty good, expectation value, if you mean it mathematically, is Sum{i=1->n}[x_i*p_i]
where p_i is the probability, the same for all i in our case with value 0.5, and x_i is the value, or our money so to speak, in our case x_i=2^i.
The problem here is that we can only have an expectation value if that sum converges, for n->oo
This is obviously not the case, so you would expect infinite money if you try "often enough" - or more mathematically correct: it's not defined.

September 24, 2009 5:15 AM  
Anonymous Anonymous said...

I 'expect' to win as much money as I can use, as I 'expect' to use my double-headed coin.

September 24, 2009 5:20 AM  
Blogger quantense said...

Oh, yeah, it should be of course N/2+1. Chris, I didn't suppose you to reply so fast and went out.

September 24, 2009 5:51 AM  
Blogger quantense said...

I would rather say (N+1)/2

September 24, 2009 5:53 AM  
Blogger Chris said...

t:b:H. You did it.

The probability of winning a lot is very small, but the expected winnings is infinite. The problem is purportedly the most famous paradox in statistics. Hence the ToM label.

The probabilty of throwing N heads followed by a tail is (1/2)*(1/2)^N. The winnings would then be 2^N. The expected (or average) winnings is Σ(2^N)*(1/2)*(1/2)^N = Σ(1/2)->∞ as N->∞.

And yes, it defies my intuition.

Anonymous. I like your thinking :) Greetz.

September 24, 2009 6:00 AM  
Blogger Chris said...

Hi quantense. I was taking a shower as I've got to visit some of my clients. I can now walk without crutches again. Your posts crossed with mine again. Greetz.

September 24, 2009 6:04 AM  
Blogger quantense said...

Hi Chris, actually after my first posting I went to the market and on my way there realized what a fool I am, because I didn't paid attention on the fact, that after n heads I should require (n+1)th tail and as a result divide prob. by 1/2. And of course I can't expect 2 dollars for 1 flip.

September 24, 2009 6:16 AM  
Blogger Chris said...

Hi quantense. I'ts easy for me because I've seen the solution - I didn't invent the problem.

Normally I avoid probabiliy problems, but the result was too interesting.

Now I must go out and earn some money.

September 24, 2009 6:40 AM  
Blogger quantense said...

Chris, have you heard this one: suppose an event A occurs in a time period of 1s with prob. 1/2. What is the prob. of A to occure in a time of 2s?
P.S. I'm glad to hear your leg is in good health now.

September 24, 2009 8:16 AM  
Anonymous t..:bH:: said...

hey chris, why go OUT to earn money?? just flip your magic coin a few times ^^

September 24, 2009 1:18 PM  
Blogger Chris said...

Hi quantense. Thanks for the well wishes. I've got a vague recollection, that probability is also 1/2 (but don't quote me on that). It's a staggering 45 years since I learnt the Poisson distribution. But you have reminded me about light bulb life expectancies.

Hi t:b:H. I don't think Anonymous would give me hs coin.

Did it qualify as a ToM problem?

September 24, 2009 2:37 PM  
Blogger Chris said...

I don't think I've given sufficient credit to quantense's contribution. Consider that to be done.

I so want to say the Poisson teaser => 3/4 probability.

September 24, 2009 3:11 PM  
Blogger Ragknot said...

Chris,

I flipped the coin one millon times. Shall I list them?

Ok, not enough space here. But can you tell me what this means.
I will list you same data. This is how many times each winning amount occured. The ONEs count the tails.

You can see, that one time I got up to $8,388,608. And there were 499,622 tails. Very close to 50/50.

The average $ amount was $25.688378
Is that what you "would expect".

My flipper finger is numb, I hope you and give us a good report on how this supports or does not support your supposition.

$ Occurances
1 499622
2 250142
4 124838
8 62612
16 31372
32 15697
64 7941
128 3944
256 1896
512 944
1024 487
2048 249
4096 124
8192 68
16384 31
32768 15
65536 9
131072 2
262144 2
524288 1
1048576 1
2097152 1
4194304 1
8388608 1

September 24, 2009 11:36 PM  
Blogger Chris said...

Hi Ragknot. Thank you. It's pretty much as I expected, the official answer doesn't seem to be completely supported by the facts. However, I expect that $25.68... is a bigger expectation that you might have expected '~'

September 25, 2009 4:09 AM  
Blogger quantense said...

Hi Chris, 3/4 is correct.

September 25, 2009 7:59 AM  
Blogger Chris said...

Hi quantense. That's a relief. My logic is better than my memory.

September 25, 2009 4:10 PM  
Blogger quantense said...

Me too. But both are awful :)

September 26, 2009 6:57 AM  
Blogger Chris said...

Same for me :)

September 26, 2009 9:33 AM  
Blogger Chris said...

A problem with this problem is that the standard deviation of the distribution is quite large (I don't actually know what the distribution or sd is). But for a million trials, the average winnings should be $500,000. i.e considerably more than the $26.88... that Ragknot achieved.

September 27, 2009 6:40 AM  
Blogger Chris said...

I've now done the experiments 10s of millions of times - I've not done a lot better that Ragknot. I keep on averaging between about $5 an $30 for the expectation (on 1 000 000 trials). I can't see a flaw in the theory. That's a result of interest.

Has anyone out there got a clue about what's going on here?

October 1, 2009 7:49 PM  
Anonymous mo said...

Hi Chris, there's a slight flaw in your reasoning in your last two posts. First of all, the expectation is always infinite, no matter whether you do one series of coin-flipping or one million -- that's the counter-intuitive part, which is given by the fact that the exponentially growing winnings just slightly outweigh the exponentially shrinking chances (by 1/2 per potential flip). That doesn't mean you can actually expect to win an infinite amount of money by flipping 1 or 10 or 1 million series. But it does mean that if you have an infinite amount of credit and time and you pay N dollars for each series you flip, you will eventually win enough to pay back your credit and take home some cash, no matter how great N is. The drawback is that billions of zillions of flips may be necessary: to win an average of N dollars per series, you would have to flip an average of 2^(2N) series. An average of 20 dollars would need an average of 1,100,000,000,000 series (each series having an average of ca. 5 flips), an average of 100 dollars would need an average of 1.6*10^60 series, each series having an average of 7-8 flips.

October 8, 2009 6:54 AM  
Blogger Chris said...

Hi mo. You don't stop flipping by choice, you only stop when you flip a tails. You pay nothing to play, you just start with $1. You will be better of by at least $1 evry time you play the game.

I can see no flaws in any of my reasoning. I only surprised that my attempts to estimate the expectation don't show a hint of infinity being reasonable. I guess the confidence in the estimated expectation is very poor with only a million trials. The statisticians really do mean than on average, you do expect to win an infinite amount per play of the game. I have probably doen 100 million trials. I agree that, in this case, vastly more trials need to be run. My PC can only do 100,000 trials per second using Mathematica (on average, so far).

Here's my Mathematica code. RandomInteger[] returns 0 and 1 with equal probability - I hope it's a high quality generator:

total = 0; winmax = 0;

For[ntrials = 0, ntrials < 1000000, ntrials++,
n = 0;
f = RandomInteger[];
While[f == 1, n++; f = RandomInteger[]]; //count #heads thrown
win = 2^n;
total += win;
If[win > winmax, winmax = win];
]
Print[{winmax, total, 1.0*total/ntrials}]

{262144,1090977,10.9098} // typical result

October 8, 2009 5:46 PM  
Blogger Chris said...

... clarification - you'd be better of by at least $1 per game if someone had given you the initial $1. You cannot lose your initial $1 or any of your winnings. So don't expect to see this exact game at a fairground ;)

October 8, 2009 5:52 PM  
Blogger Chris said...

... I just changed the terminate game condition to if f == 0 (as a quick check on the random number generator), but get similar results. Also note my win variable includes the first $1, so if you throw a tails straight away, you end up with win = $1.

October 8, 2009 5:59 PM  
Anonymous mo said...

Hi Chris, I am aware that with the initial rules you can only win, I was just illustrating what "infinite expectation" means with an example. It is imaginable that a fairground or a casino might adopt a version where you have to pay to flip a series and keep the winnings (by series I mean that you start with $1 and flip until you flip tails). But they would be ill-advised to do so, no matter how much they charge. That doesn't mean it's likely that their first customer will break the bank, but sooner or later someone will win every profit the bank had ever made with the game. Thats a mathematical fact, it's only a matter of time -- although with a large N that would probably be a very, very long time.

In other words: for every E → ∞ (expectation) there exists an n for which ∑ W(i) > n*E, with W(i) being the winnings of the i-th series and i running from 1 to n. That is counter-intuitive, but it does not mean "you can expect to win infinite amounts whenever you play the the coin-flipping game".

As for your simulated trials, no, you can't expect to see "a hint of infinity", all can expect to see is that the overall average winnings per series is growing, the more trials you do. It would be growing extremely slowly (as mentioned above, after 1.6*10^60 series the average would barely be $100), but growing nonetheless -- that's all that "infinite expectation" means.

October 10, 2009 10:59 AM  
Blogger Chris said...

Hi mo. I'd actually written quite a lot of stuff after your last post. But I've just deleted it as it became redundant. i.e. The penny has finally dropped. The standard deviation of the winnings is probably huge (I would guess infinitely so, unless your 1.6*10^60 is closer to the true value). I now understand (coupled with sketching the distribution) why the 1 million trials experiments give such wild and low results.

I'm sorry about the first para of my Oct 8 post. It was in part because I don't like changing to another problem (even as an analogy) - although I'm guilty of offering them myself. I only usually do that when all other paths seem to have been exhausted. I'm wary of analogies, a small difference could lead to significant differences: as has recently been illustrated in the robbers problem.

I already knew what expectation means. By pure coincidence, I had amended the problem header to reflect that, a mere half an hour before your last post.

Thanks you for posting back. You've helped me to understand what's going on. Greetings.

October 10, 2009 3:08 PM  
Blogger Chris said...

My highest winnings in about 2 billion games is $536 870 912. That's 29 heads before the tail. The highest average I've noticed was about $40 - not sure of the size of the trial though.

October 11, 2009 2:52 PM  

Post a Comment

Links to this post:

Create a Link

<< Home