Last active
January 11, 2021 06:24
-
-
Save pjoshi30/680e19d5946effdbac143c9936e7e223 to your computer and use it in GitHub Desktop.
WRBO[1:d] calculation to determine the value of p
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 | |
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