Created
November 5, 2017 17:52
-
-
Save Allianzcortex/573c8e540ebcf1d65e19f1b6eeb9840b to your computer and use it in GitHub Desktop.
probability_cal.py
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 characters
from random import randint | |
def cal(): | |
all_time = [] | |
cash,count = 1,0 | |
target = 100000 | |
for i in xrange(0,10): | |
while True: | |
cash = cash* 2 if randint(0,1)==0 else 1 | |
count += 1 | |
print count,cash | |
if cash >= target: | |
all_time.append(count) | |
break | |
print max(all_time),min(all_time),sum(all_time)/len(all_time) | |
if __name__=='__main__': | |
cal() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment