-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Hi,
I am using this Celerite code for very first time. In my study, I am modeling a data set with SHO model. As documented, I am following all step like, set the prior values for SHO model, when I run the code and simulate data, outcome containing error given as :
In first place code is given -
""""""""". code """""""""""""""
import celerite
from celerite import terms
Q3 = 1.0 / np.sqrt(2.0)
w3 = 0.008
S3 = np.var(y) / (w3 * Q3)
bounds_non_periodic = dict(log_S0=(-10, 10), log_Q=(-10, 10), log_omega0=(-10, 10))
kernel3 = terms.SHOTerm(log_S0=np.log(S3), log_Q=np.log(Q3), log_omega0=np.log(w3))
#kernel3.freeze_parameter("log_Q")
kernel_combined = kernel3
gp = celerite.GP(kernel_combined)
gp.compute(MJD, dy) # You always need to call compute once.
print("Initial log likelihood: {0}".format(gp.log_likelihood(y)))
from scipy.optimize import minimize
def neg_log_like(params, y, gp):
gp.set_parameter_vector(params)
return -gp.log_likelihood(y)
initial_params = gp.get_parameter_vector()
bounds = gp.get_parameter_bounds()
r = minimize(neg_log_like, initial_params, method="L-BFGS-B", bounds=bounds, args=(y, gp))
gp.set_parameter_vector(r.x)
print(r)
x = np.linspace(np.min(MJD), np.max(MJD), 500)
pred_mean, pred_var = gp.predict(y, x, return_var=True)
pred_std = np.sqrt(pred_var)
pred_mean
"""""""""""""""""""""""""""""""""""""""""""""""""""""
Error : - when I generate the mean and var using gp.predict command, getting outcome as :
array([3.07314316e-08, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
nan, nan, nan, nan,
why is that, why am i getting "nan"?
I have gone through many article in which used oscillator models are written as : SHO * n, where n <= 4, how to build a kernel for this ?