Skip to content

Instantly share code, notes, and snippets.

@behrouz-bakhtiari
Last active November 2, 2021 02:09
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 behrouz-bakhtiari/491ee08da296169e996b00762a41a7d4 to your computer and use it in GitHub Desktop.
Save behrouz-bakhtiari/491ee08da296169e996b00762a41a7d4 to your computer and use it in GitHub Desktop.
import scipy.special as special
from math import comb
K = 18 # number of sections
def survival_prob(r , K):
probability = 2 ** (-K-1) * comb(K, r-1) * special.hyp2f1(1, 1+K, 2 + K - r, 1/2)
return probability
def main():
for r in range(16):
if r <= K:
p = survival_prob(r + 1, K)
else:
p = 1.0
print(f'Probability of survival for player {r+1} is {p}!')
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment