Skip to content
Snippets Groups Projects
Commit 5de653b8 authored by Matthew David Pitkin's avatar Matthew David Pitkin
Browse files

prior.py: add pymc3_prior method to Gaussian prior

parent 1abfa584
No related branches found
No related tags found
1 merge request!139Add PyMC3 sampler
......@@ -802,7 +802,7 @@ class Sine(Prior):
class Gaussian(Prior):
def __init__(self, mu, sigma, name=None, latex_label=None):
def __init__(self, mu, sigma, name=None, latex_label=None, use_pymc3=False):
"""Gaussian prior with mean mu and width sigma
Parameters
......@@ -820,7 +820,7 @@ class Gaussian(Prior):
latex_label: str
See superclass
"""
Prior.__init__(self, name, latex_label)
Prior.__init__(self, name, latex_label, use_pymc3=use_pymc3)
self.mu = mu
self.sigma = sigma
......@@ -849,6 +849,14 @@ class Gaussian(Prior):
def lnprob(self, val):
return -0.5 * ((self.mu - val) ** 2 / self.sigma ** 2 + np.log(2 * np.pi * self.sigma ** 2))
def pymc3_prior(self, sampler):
priortype = 'Normal'
priorargs = {}
priorargs['mu'] = self.mu
priorargs['sd'] = self.sigma
return self.set_pymc3_prior(sampler, priortype, **priorargs)
def __repr__(self):
"""Call to helper method in the super class."""
return Prior._subclass_repr_helper(self, subclass_args=['mu', 'sigma'])
......
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