Priors¶
These are classes for the priors.
-
class
cascade_at.model.priors.
_Prior
¶ All priors have these methods.
-
parameters
()¶ Returns a dictionary of all parameters for this prior, including the prior type as “density”.
-
assign
(parameter=value, parameter=value...)¶ Creates a new Prior object with the same parameters as this Prior, except for the requested changes.
-
-
class
cascade_at.model.priors.
Uniform
(lower, upper, mean=None, eta=None, name=None)[source]¶ - Parameters
lower (float) – Lower bound
upper (float) – Upper bound
mean (float) – Doesn’t make sense, but it’s used to seed solver.
eta (float) – Used for logarithmic distributions.
name (str) – A name in case this is a pet prior.
-
class
cascade_at.model.priors.
Constant
(mean, name=None)[source]¶ - Parameters
mean (float) – The const value.
name (str) – A name for this prior, e.g. Susan.
-
class
cascade_at.model.priors.
Gaussian
(mean, standard_deviation, lower=- inf, upper=inf, eta=None, name=None)[source]¶ A Gaussian is
\[f(x) = \frac{1}{2\pi \sigma^2} e^{-(x-\mu)^2/(2\sigma^2)}\]where \(\sigma\) is the variance and \(\mu\) the mean.
- Parameters
mean (float) – This is \(\mu\).
standard_deviation (float) – This is \(\sigma\).
lower (float) – lower limit.
upper (float) – upper limit.
eta (float) – Offset for calculating standard deviation.
name (str) – Name for this prior.
-
class
cascade_at.model.priors.
Laplace
(mean, standard_deviation, lower=- inf, upper=inf, eta=None, name=None)[source]¶ This version of the Laplace distribution is parametrized by its variance instead of by scaling of the axis. Usually, the Laplace distribution is
\[f(x) = \frac{1}{2b}e^{-|x-\mu|/b}\]where \(\mu\) is the mean and \(b\) is the scale, but the variance is \(\sigma^2=2b^2\), so the Dismod-AT version looks like
\[f(x) = \frac{1}{\sqrt{2\pi\sigma^2}}e^{-\sqrt{2}|x-\mu|/\sigma}.\]The standard deviation assigned is \(\sigma\).
-
class
cascade_at.model.priors.
StudentsT
(mean, standard_deviation, nu, lower=- inf, upper=inf, eta=None, name=None)[source]¶ This Students-t must have \(\nu>2\). Students-t distribution is usually
\[f(x,\nu) = \frac{\Gamma((\nu+1)/2)}{\sqrt{\pi\nu}\Gamma(\nu)}(1+x^2/\nu)^{-(\nu+1)/2}\]with mean 0 for \(\nu>1\). The variance is \(\nu/(\nu-2)\) for \(\nu>2\). Dismod-AT rewrites this using \(\sigma^2=\nu/(\nu-2)\) to get
\[f(x) = \frac{\Gamma((\nu+1)/2)}{\sqrt(\pi\nu)\Gamma(\nu/2)} \left(1 + (x-\mu)^2/(\sigma^2(\nu-2))\right)^{-(\nu+1)/2}\]
-
class
cascade_at.model.priors.
LogGaussian
(mean, standard_deviation, eta, lower=- inf, upper=inf, name=None)[source]¶ Dismod-AT parametrizes the Log-Gaussian with the standard deviation as
\[f(x) = \frac{1}{\sqrt{2\pi\sigma^2}} e^{-\log((x-\mu)/\sigma)^2/2}\]-
mle
(draws)[source]¶ Assign new mean and stdev, with mean clamped between upper and lower. This does a fit using a normal distribution.
- Parameters
draws (np.ndarray) – A 1D array of floats.
- Returns
With mean and stdev set, where mean is between upper and lower, by force. Upper and lower are unchanged.
- Return type
Gaussian
-
-
class
cascade_at.model.priors.
LogLaplace
(mean, standard_deviation, eta, lower=- inf, upper=inf, name=None)[source]¶
-
class
cascade_at.model.priors.
LogStudentsT
(mean, standard_deviation, nu, eta, lower=- inf, upper=inf, name=None)[source]¶ -
mle
(draws)[source]¶ Assign new mean and stdev, with mean clamped between upper and lower. This does a fit using a normal distribution.
- Parameters
draws (np.ndarray) – A 1D array of floats.
- Returns
With mean and stdev set, where mean is between upper and lower, by force. Upper and lower are unchanged.
- Return type
Gaussian
-