A game is played starting with 6 fair coins laid out with heads face up.
Each round consists of flipping all of the coins showing heads.
If an even number of coins is flipped and an even number of heads comes up the player loses.
If an odd number of coins is flipped and an odd number of heads comes up the player loses.
Rounds continue until the player either loses or reaches zero heads.
The player wins by getting to zero heads without losing.
What is the probability of winning this game?
Examples:
6→3→1 would be a loss.
6→3→0 would be a win.
6→0 would be a loss (even→even rule is applied first.)
In the table below, the probabilities are built up as Steve Herman started, recursing to previously calculated values:
N Total
1 1/2 * 1 1/2 * 0 1/2
2 1/4 * 0 1/2 * 1/2 1/4 * 0 1/4
3 1/8 * 1 3/8 * 0 3/8 * 1/4 1/8 * 0 7/32
4 1/16 * 0 1/4 * 1/2 3/8 * 0 1/4 * 7/32 1/16 * 0 23/128
5 1/32 * 1 5/32 * 0 5/16 * 1/4 5/16 * 0 5/32 * 23/128 1/32 * 0 563/4096
6 1/64 * 0 3/32 * 1/2 15/64 * 0 5/16 * 7/32 15/64 * 0 3/32 * 563/4096 1/64 * 0 16793/131072
The first product on each row is the probability of getting zero heads times the probability of winning given that one has gotten zero heads. The second product is for getting 1 heads, etc. up to getting all heads. Getting all heads is an immediate loss as the parity of N matches that of N, as it's the same number.
For example, in the nonparity matches for 6, as at the beginning, the probability of getting 1 heads is 3/32, and in that instance, the conditional probability of eventually winning is 1/2. For getting 3 heads, the probability is 5/16 and its conditional probability is 7/32. For getting 5 heads, the probability is 3/32 and the previously calculated probability is 563/4096. These products add up to 16793/131072, the final answer.
5 point 10
9 for Nbr=1 to 6
10 print Nbr,1fnPLose(Nbr)
11 next Nbr
20 end
30
40 fnPLose(N)
50 local Pl,H,Ph,Totph
60 Pl=0:if N=0 then goto 150
70 for H=0 to N
80 Ph=combi(N,H)//2^N
85 if N=Nbr then print Ph;"*";
90 if H @ 2<>N @ 2 then
100 :Pl=Pl+Ph*fnPLose(H)
101 :if N=Nbr then print 1fnPLose(H);:endif
110 :else
120 :Pl=Pl+Ph
121 :if N=Nbr then print 0;:endif
130 :endif
140 next H
150 return(Pl)

Posted by Charlie
on 20110129 15:45:03 