from __future__ import division numbers = range(1,180) worth = 10 o_worth = worth ev = 0 # winning as fraction of new reference point def val(x,w): return x/(x+w) def win(number): return 2**number # our worth is only updated once def one_update(n): winnings = win(n) odds = 1/winnings value = val(winnings, worth) * odds return value # we update our worth each time we win a bettuple() def multiple_updates(n): global worth winnings = win(n) odds = 1/winnings value = val(winnings, worth) * odds worth = worth+winnings return value ev = sum([one_update(n) for n in numbers]) print "ev",ev *o_worth, "for", n print ev*o_worth/(1-ev) ev = sum([multiple_updates(n) for n in numbers]) print "ev",ev *o_worth, "for", n print ev*o_worth/(1-ev)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question