Skip to content

Instantly share code, notes, and snippets.

@pjoshi30
Last active January 11, 2021 06:24
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 pjoshi30/680e19d5946effdbac143c9936e7e223 to your computer and use it in GitHub Desktop.
Save pjoshi30/680e19d5946effdbac143c9936e7e223 to your computer and use it in GitHub Desktop.
WRBO[1:d] calculation to determine the value of p
import math
import numpy as np
p = 0.9
d = 10
def sum_series(p, d):
# tail recursive helper function
def helper(ret, p, d, i):
term = math.pow(p, i)/i
if d == i:
return ret + term
return helper(ret + term, p, d, i+1)
return helper(0, p, d, 1)
wrbo1_d = 1 - math.pow(p, d-1) + (((1-p)/p) * d *(np.log(1/(1-p)) - sum_series(p, d-1)))
print(wrbo1_d) # Output: 0.8555854467473518
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment