Author 
Topic: More heads than tails (Read 17345 times) 

ThudnBlunder
wu::riddles Moderator Uberpuzzler
The dewdrop slides into the shining Sea
Gender:
Posts: 4489


More heads than tails
« on: Nov 11^{th}, 2003, 8:40pm » 
Quote Modify

You flip a fair twosided coin until you have either n more heads than tails or m more tails than heads. What is the expected average number of flips that you willl need? // title modified by wwu july 27 2004

« Last Edit: Jul 27^{th}, 2004, 4:44am by william wu » 
IP Logged 
THE MEEK SHALL INHERIT THE EARTH.....................................................................er, if that's all right with the rest of you.



towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13647


Re: More Coin Tossing
« Reply #1 on: Nov 12^{th}, 2003, 1:54pm » 
Quote Modify

::I might be mistaken, but is this a very difficult way to do a very simple operation??:: [e]the following recursion holds, and conveniently fits with the solution I was thinking of. e(n,0) = 0 e(0,m) = 0 e(n,m) = 1/2 (e(n1, m+1) + e(n+1, m1)) +1 (when n>0, m>0)[/e]

« Last Edit: Nov 12^{th}, 2003, 2:17pm by towr » 
IP Logged 
Wikipedia, Google, Mathworld, Integer sequence DB



william wu
wu::riddles Administrator
Gender:
Posts: 1291


Re: More Coin Tossing
« Reply #2 on: Jul 27^{th}, 2004, 4:41am » 
Quote Modify

You can think of this as simply a random walk on the integers, with increments of +1 and 1. Let heads correspond to +1 and tails correspond to 1. At each time step 1,2,.... a random variable X_{i} is generated, equally likely to be either +1 or 1. Then our random walk corresponds to the cumulative sum of these variables: S_{n} = S_{0} + [sum]_{i=1 to n} X_{i} where S_{0} is the initial position. We then want to know the expected time till this walk hits either n or m. To do this, we can set up a recursion. The underlying principle is that after you have moved somewhere, the problem of computing the remaining expected hitting time is just like the problem you started with, except that the initial position S_{0} has changed. Let T be the random variable denoting the time till either level n or level m is hit. Then we want to find E[T]. Let h(k) = E(T  S_{0} = k). Then, finishing what towr started, we have the recursion h(k) = 0.5 h(k1) + 0.5 h(k+1) + 1 with boundary conditions 0 = h(n) = h(m). To solve this recurrence quickly, consider the discrete forward difference operator [smiley=cdelta.gif]h(k1) = h(k)  h(k1) Invoking the operator twice on h(k1) then yields [smiley=cdelta.gif]^{2} h(k1) = h(k+1)  2h(k) + h(k1) Note that is highly resemblant of our original recurrence equation. In fact we can now express the recurrence as 1 = (1/2) [smiley=cdelta.gif]^{2} h(k1) Thus the function h has a constant second difference. This suggests a quadratic expression for h, with the highestorder coefficient scaled by [smiley=cdelta.gif]^{2} h(k1) / 2 = 1. By also considering the boundary conditions 0 = h(n) = h(m), we make the educated guess h(k) = (k  n)(k + m) whose correctness can be verified by substitution into the original recurrence. Now recall that h(k) = expected hitting time given that the initial position is k. Thus our final answer is very, very elegant: h(0) = (0  n)(0 + m) = nm. (SWEET!)

« Last Edit: Aug 3^{rd}, 2004, 6:17pm by william wu » 
IP Logged 
[ wu ] : http://wuriddles.com / http://forums.wuriddles.com



