Skip to content

Instantly share code, notes, and snippets.

@Allianzcortex
Created November 5, 2017 17:52
Show Gist options
  • Save Allianzcortex/573c8e540ebcf1d65e19f1b6eeb9840b to your computer and use it in GitHub Desktop.
Save Allianzcortex/573c8e540ebcf1d65e19f1b6eeb9840b to your computer and use it in GitHub Desktop.
probability_cal.py
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