Skip to content

Instantly share code, notes, and snippets.

@jilm
Created May 18, 2019 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jilm/463ed9220a6e1bb50e83922c38d50c3e to your computer and use it in GitHub Desktop.
Save jilm/463ed9220a6e1bb50e83922c38d50c3e to your computer and use it in GitHub Desktop.
import math
def poisson(lmbd, k):
return math.exp(-lmbd + k * math.log(lmbd) - math.lgamma(k+1))
def poisson_cumulative(lmbd, s):
return sum([poisson(lmbd, k) for k in range(s+1)])
def mean_cost(lmbd, cr, u):
return sum([cr * (u-v) * poisson(lmbd, v) for v in range(u+1)]) + 1.0 - poisson_cumulative(lmbd, u)
def get_gnuplot_data_game1(lmbd=5, cr=0.1, range=100):
for u in range(range)
j_1 = sum([cr * (u-v) * poisson(lmbd, v) for v in range(u+1)])
j_2 = 1.0 - poisson_cumulative(lmbd, u)
print('{} {} {} {}'.format(u, j_1, j_2, j_1 + j_2))
def get_gnuplot_data_game2(lmbd=5, cr=(0.1, 0.05, 0.001), range=100):
for u in range(range):
print('{} {}'.format(
' '.join([mean_cost(lmbd, c, u) for c in cr])
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment