You play a coin flipping game with 5 coins. On round 1 you flip all of them. On round 2, you pick up all the ones that came up tails (leaving all the heads alone) and flip them again. You continue to do this until all the coins are heads. For example:
Round 1: H T T H T
Round 2: - H T - H
Round 3: - - T - -
Round 4: - - T - -
Round 5: - - H - -
Done in 5 Rounds.
What is the expected number of rounds you'll need to finish the game?
What is the probability you will finish the game in 3 rounds or less?
A simulation of 1,000,000 trials involved a total of 3,795,409 rounds of tosses, for an average of 3.795409 per trial.
DEFLNG A-Z
RANDOMIZE TIMER
FOR tr = 1 TO 1000000
REDIM hit(5): hits = 0: round = 0
DO
round = round + 1
FOR i = 1 TO 5
IF hit(i) = 0 THEN
flip = INT(RND(1) * 2)
IF flip THEN
hit(i) = 1: hits = hits + 1
END IF
END IF
NEXT
LOOP UNTIL hits = 5
trials = trials + 1
tot = tot + round
NEXT tr
PRINT tot, trials, tot / trials
|
Posted by Charlie
on 2004-10-13 18:58:19 |