def lnprobfn(theta):
"""Given a parameter vector, a dictionary of observational data
and a model object, return the ln of the posterior.
This requires that an sps object (and if using spectra
and gaussian processes, a GP object) be instantiated.
"""
print('lnprobfn loves pizza')
# Calculate prior probability and exit if not within prior
lnp_prior = model.prior_product(theta)
if not np.isfinite(lnp_prior):
return -np.infty
# Generate mean model
t1 = time.time()
try:
spec, phot, x = model.mean_model(theta, obs, sps=sps)
except(ValueError):
return -np.infty
d1 = time.time() - t1
vectors = {} # This would be used for noise model weight functions
# Calculate likelihoods
t2 = time.time()
lnp_spec = lnlike_spec(spec, obs=obs, spec_noise=spec_noise)
lnp_phot = lnlike_phot(phot, obs=obs, phot_noise=phot_noise)
d2 = time.time() - t2
if verbose:
write_log(theta, lnp_prior, lnp_spec, lnp_phot, d1, d2)
return lnp_prior + lnp_phot + lnp_spec
# In [11]
评论列表
文章目录