I'm quite ashamed to be stuck with a Gambler's Ruin problem, I guess I'm missing some basic statistical intuition here:
Three fair coins tossed. Heads gets +1, tails -1, pay-offs are added and net pay-off added to equity. The 3 tosses are repeated 1000 times. Initial equity is 10 $ . What is the probability of total ruin (within +/- 0.05 error)?
I simulated the problem as 3 iid coin tosses in one round which is then repeated, the same as it would be with a repeated one coin toss. My simulated probability of ruin converges to ca. 83%, while 100% would be the correct answer. The only hint I have is 'Flipping a coin in succession is different from flipping three concurrently from markov lens'. Could someone help me and explain?
Thanks!!
Tobi
import numpy as np
class GamblersRuin(object):
"""
Three fair coins tossed. Heads gets +1, tails -1, pay-offs are added and net pay-off
added to equity.
The 3 tosses are repeated 1000 times. Initial equity is 10 dollars
p: probability that gambler is successful/ wins at each round.
i: gambler's initial amount of money/reserves
"""
def __init__(self, p, init_bal):
self.p = p
self.init_bal = init_bal
self.bal = init_bal
self.q = 1 - self.p
self.realizations = np.array(self.init_bal)
self.simulation_results = []
def coin_toss(self):
"""
One coin flip with payoff (1, -1) with probability (p,q)
"""
outcome = np.random.uniform(0, 1)
if outcome < self.p:
result = 1
else:
result = -1
return result
def play_one_round(self):
"""
Three coin tosses in one round round
"""
result_round = 0
for i in range(0,3):
result_round += self.coin_toss()
return result_round
def gamble(self, no_rounds):
"""
One round is played until ruin or no_rounds times
"""
self.realizations = np.array(self.init_bal)
self.bal = self.init_bal
round = 1
while round < no_rounds:
round_result = self.play_one_round()
if (self.bal + round_result) >= 0:
self.bal += round_result
else:
break
self.realizations = np.append(self.realizations, self.bal)
round += 1
def simulate(self, no_simulations, no_rounds):
# Gamble multiple times and store realization paths
self.simulation_results = []
for game in range(1,no_simulations+1):
self.gamble(no_rounds=no_rounds)
self.simulation_results.append(self.realizations)