Source code for heron.priors

from scipy import stats
from scipy.special import ndtri

[docs]class Prior(object): """ A prior probability distribution. """ pass
[docs]class Normal(Prior): """ A normal prior probability distribution. """ def __init__(self, mean, std): self.mean = mean self.std = std distro = stats.norm(self.mean, self.std)
[docs] def logp(self, x): return distro.logpdf(x)
[docs] def transform(self, x): """ Transform from unit normalisation to this prior. Parameters ---------- x : float The position in the normalised hyperparameter space """ return self.mean + self.srd * ndtri(x)