I encountered a problem where I have to do the following calculation:
N = 250
H = 140
bayes_factor = factorial(H) * factorial(N-H) / factorial(N+1) / (0.5**N)
How to solve the problem: I tried:
from scipy.special import factorial
bayes_factor = (factorial(H) * factorial(N-H)) / factorial(N+1) / (0.5**N)
It gives infinity.
Update: typo fixed in the denominator factorial(H+1) should be factorial(N+1).
Note: the answer should come around 0.5 as the coin might be unbiased.
The answer is appreciated.
factorial(H)/factorial(H+1)is just1/(H+1).factorial(N-H)as you haveNandHdefined). I suspect these values are too absurdly large to realistically work with for you.