Commit dd069b53 authored by Moritz's avatar Moritz

Moved log likelihood calculation into log space

parent 7eec0659
Pipeline #69894 passed with stage
in 7 minutes and 19 seconds
......@@ -117,7 +117,7 @@ class AnalyticalMultidimensionalBimodalCovariantGaussian(bilby.Likelihood):
def log_likelihood(self):
x = np.array([self.parameters["x{0}".format(i)] for i in range(self.dim)])
return np.log(0.5 * (self.pdf_1.pdf(x) + self.pdf_2.pdf(x)))
return -np.log(2) + np.logaddexp(self.pdf_1.logpdf(x), self.pdf_2.logpdf(x))
label = "multidim_gaussian_unimodal"
......@@ -125,7 +125,7 @@ outdir = "outdir"
likelihood = AnalyticalMultidimensionalCovariantGaussian(mean, cov)
priors = bilby.core.prior.PriorDict()
priors.update({"x{0}".format(i): bilby.core.prior.Uniform(-40, 40, "x{0}".format(i)) for i in range(dim)})
priors.update({"x{0}".format(i): bilby.core.prior.Uniform(-5, 5, "x{0}".format(i)) for i in range(dim)})
result = bilby.run_sampler(
likelihood=likelihood,
......@@ -165,7 +165,7 @@ mean_2 = -4 * np.sqrt(np.diag(cov))
likelihood = AnalyticalMultidimensionalBimodalCovariantGaussian(mean_1, mean_2, cov)
priors = bilby.core.prior.PriorDict()
priors.update({"x{0}".format(i): bilby.core.prior.Uniform(-2, 2, "x{0}".format(i)) for i in range(dim)})
priors.update({"x{0}".format(i): bilby.core.prior.Uniform(-5, 5, "x{0}".format(i)) for i in range(dim)})
result = bilby.run_sampler(
likelihood=likelihood,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment