Sage Probability

asked 2013-10-01 05:42:12 -0500

Komolo gravatar image

updated 2015-05-24 08:28:00 -0500

FrédéricC gravatar image

Please help me write a sage function for the following problem:

Suppose a gambler starts with R1000. He repeatedly plays a game where the initial bet is R100. The gambler has a 60% chance of losing the game (in which case he gets nothing), but a 40% chance of winning and doubling his money (ie, he gets back R200). If the gambler loses all of his money, he is ruined and stops playing. If the gambler reaches R2000, he also stops playing. Otherwise, the gambler keeps playing. What is the probability that the gambler stops with R2000? What is the probability he is ruined?

Write a simulation to empirically determine the probabilities. Run your simulation 10000 times. What are the probabilities for ruin and winning?

edit retag flag offensive close merge delete