Created
February 3, 2016 07:35
-
-
Save dooglus/1426a596d59b722d3312 to your computer and use it in GitHub Desktop.
Revisions
-
dooglus created this gist
Feb 3, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ 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