Last active
October 30, 2015 22:11
-
-
Save stucchio/8824537 to your computer and use it in GitHub Desktop.
For a forthcoming blog post.
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 pylab import * | |
from scipy.stats import uniform | |
gamma = 0.01/12.0 | |
t = arange(0,360) | |
def compute_payout(payout): | |
return (payout * exp( - gamma * t)).sum() | |
def generate_payout(): | |
payout = ones(shape=(1,360)) * 100 | |
for k in range(360): | |
if uniform().rvs() < 0.01/12.0: | |
payout[:,k:] = 0.0 | |
return payout | |
N = 100000 | |
values = zeros(shape=(N,), dtype=float) | |
for i in range(N): | |
values[i] = compute_payout(generate_payout()) | |
hist(values, bins=50, normed=True) | |
xlabel("Total payout") | |
ylabel("Approximate probability density") | |
show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment