Skip to content
Snippets Groups Projects
Commit bb5144f9 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Use either lnprobs or probs

parent 10ac7392
No related branches found
No related tags found
1 merge request!41Add hyper-parameter likelihood
......@@ -168,8 +168,22 @@ class HyperparameterLikelihood():
self.hyper_prior = hyper_prior
self.run_prior = run_prior
self.parameters = parameters
if hasattr(hyper_prior, 'lnprob') and hasattr(run_prior, 'lnprob'):
logging.info("Using log-probabilities in likelihood")
self.log_likelihood = self.log_likelihood_using_lnprob
else:
logging.info("Using probabilities in likelihood")
self.log_likelihood = self.log_likelihood_using_prob
def log_likelihood(self):
def log_likelihood_using_prob(self):
L = []
self.hyper_prior.__dict__.update(self.parameters)
for samp in self.samples:
f = self.hyper_prior.lnprob(samp) - self.run_prior.lnprob(samp)
L.append(logsumexp(f))
return np.sum(L)
def log_likelihood_using_lnprob(self):
L = []
self.hyper_prior.__dict__.update(self.parameters)
for samp in self.samples:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment