Created
February 3, 2016 07:35
-
-
Save dooglus/1426a596d59b722d3312 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random, math | |
num_sims = 1000 | |
num_rolls = 1000 | |
chance = 5/100.0 | |
edge = 1 - 2*chance | |
start_bank = 1000 | |
risk = 0 | |
while risk < 1: | |
sim_count = 0 | |
sum_log_banks = 0 | |
while sim_count < num_sims: | |
bank = start_bank | |
roll_count = 0 | |
while roll_count < num_rolls: | |
if random.random() < chance: | |
bank *= (1-risk) | |
else: | |
bank *= (1+risk) | |
roll_count += 1 | |
sum_log_banks += math.log(bank/start_bank) | |
sim_count += 1 | |
print risk, sum_log_banks / sim_count | |
risk += 0.01 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment