A and B each put 10 coins in the
pot. A then takes a coin from the pot
and tosses it, while B calls heads or
tails. If B’s call is correct, he takes
the coin and keeps it; otherwise, A
keeps the coin. B then takes a coin
from the remaining pot and tosses it
while A calls heads or tails.
The play
continues in this way until one player
has accumulated 10 coins, whereupon
he wins the game and takes all the
coins remaining in the pot. At one
point in the play, A has six coins,
while B has only four. What is A’s
probability of winning?
When the
situation occurs in a game such that
one player has won six coins while
his opponent has won four coins,
what is the expected value of the
winnings (net number of coins) of the
player with six coins?
A Monte Carlo sim with 10^7 reps finds:
A prob of winning: 0.7458705
Expected winnings without pot: 7.458705
Expected winnings including pot: 9.9343274
------
# Monte Carlo
import random
A_wins = 0
B_wins = 0
A_winnings = 0
A_winnings_plus_pot = 0
reps = 10000000
for iter in range(reps):
A = 6
B = 4
over = False
while not over:
if random.random() > .5:
A += 1
else:
B += 1
if A >= 10:
A_wins += 1
A_winnings += A
A_winnings_plus_pot += 20 - B
over = True
if B >= 10:
B_wins += 1
over = True
print('A prob of winning:', A_wins / (A_wins + B_wins))
print('Expected winnings without pot:', A_winnings / reps)
print('Expected winnings including pot:', A_winnings_plus_pot / reps)
|
Posted by Larry
on 2025-01-13 09:42:59 |