Created
May 18, 2019 15:59
-
-
Save jilm/463ed9220a6e1bb50e83922c38d50c3e to your computer and use it in GitHub Desktop.
This file contains 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
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