I am using EMCEE. I write a part which problem is risen from there in the following.
I ran into this error
ValueError: lnprob returned NaN.
this error interrupts the calculation and I do not know how to overcome. So, I should do something to pass this error in order to continue the rest of computation.
The only things came to my mind is to add a line in lnprob
function like:
if not np.isfinite(lp):
return -np.inf
if np.isnan(lp):
return -np.inf
but it is not correct
the code is:
def log_prior(H0, od0, c, b, Orc, M):
if 0.4 < od0 < 0.9 and 50 < H0 < 90 and 0 < c < 3 and 0 < b < 1 and -0.3 < M < 0.2 and 0 < Orc < 0.1:
return 0.0
return -np.inf
def lnlike(H0, od0, c, b, Orc, M):
lg = -chi2(H0, od0, c, b, Orc, M)/2.
return lg
def lnprob(H0, od0, c, b, Orc, M):
lp = log_prior(H0, od0, c, b, Orc, M)
if not np.isfinite(lp):
return -np.inf
return lp + lnlike(H0, od0, c, b, Orc, M)
def func(theta):
H0, od0, c, b, Orc, M = theta
return -2. * lnprob(H0, od0, c, b, Orc, M)
I appreciate your help.