Skip to content
Snippets Groups Projects

Add PyMC3 sampler

Merged Matthew David Pitkin requested to merge matthew-pitkin/bilby:pymc3 into master
3 files
+ 85
29
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 10
9
@@ -123,16 +123,17 @@ class GaussianLikelihood(Likelihood):
if samplername != 'pymc3':
raise ValueError("Only use this class method for PyMC3 sampler")
model_parameters = dict()
for key in sampler.priors:
if key == 'sigma' and self.sigma is None:
self.sigma = sampler.priors[key].pymc3_prior(sampler)
if 'sigma' in sampler.pymc3_priors:
# if sigma is suppled use that value
if self.sigma is None:
self.sigma = sampler.pymc3_priors.pop('sigma')
else:
if key in self.function_keys:
model_parameters[key] = sampler.priors[key].pymc3_prior(sampler)
else:
raise ValueError("Prior key '{}' is not a function key!".format(key))
del sampler.pymc3_priors['sigma']
model = self.function(self.x, **model_parameters)
for key in sampler.pymc3_priors:
if key not in self.function_keys:
raise ValueError("Prior key '{}' is not a function key!".format(key))
model = self.function(self.x, **sampler.pymc3_priors)
return sampler.external_sampler.Normal('likelihood', mu=model, sd=self.sigma, observed=self.y)
\ No newline at end of file
Loading