ravest.prior

Prior probability distributions for Bayesian fitting.

Attributes

PRIOR_FUNCTIONS

Classes

Uniform

Log of uniform prior distribution, with closed (inclusive) interval [a,b].

EccentricityUniform

Log Uniform prior for eccentricity. Uses half-open interval [0, upper).

Normal

Log of Normal prior distribution.

TruncatedNormal

Log of properly normalized truncated Normal prior distribution.

HalfNormal

Log of half-Normal prior distribution.

Rayleigh

Log of Rayleigh prior distribution.

VanEylen19Mixture

Log of a Rayleigh & Half-Normal mixture model prior distribution.

Beta

Log of Beta prior distribution, for parameter x where 0 <= x <= 1.

Module Contents

ravest.prior.PRIOR_FUNCTIONS = ['Uniform', 'EccentricityUniform', 'Normal', 'TruncatedNormal', 'HalfNormal', 'Rayleigh',...
class ravest.prior.Uniform(lower: float, upper: float)[source]

Log of uniform prior distribution, with closed (inclusive) interval [a,b].

The uniform probability distribution is:

\[\begin{split}p(x) = \frac{1}{b - a} \quad \text{for} \quad a \leq x \leq b \\ 0 \quad \text{otherwise}\end{split}\]

The log probability is:

\[\begin{split}\log p(x) = -\log{(b - a)} \quad \text{for} \quad a \leq x \leq b \\ -\inf \quad \text{otherwise}\end{split}\]

Uses closed interval [a, b] - both boundary values are included. Note that for usage on eccentricity, we recommend EccentricityUniform instead, which uses a half-open interval [0, upper) to allow exactly e=0 (circular orbits) whilst excluding e=upper (to allow e up to, but not including, 1).

Parameters:
  • lower (float) – Lower bound of the uniform distribution.

  • upper (float) – Upper bound of the uniform distribution.

lower
upper
__call__(value: float) float[source]

Calculate log uniform prior probability.

Parameters:

value (float) – Parameter value to evaluate

Returns:

Log prior probability

Return type:

float

__repr__() str[source]
class ravest.prior.EccentricityUniform(upper: float)[source]

Log Uniform prior for eccentricity. Uses half-open interval [0, upper).

The uniform probability distribution is:

\[\begin{split}p(x) = \frac{1}{b} \quad \text{for} \quad 0 \leq x < b \\ 0 \quad \text{otherwise}\end{split}\]

The log probability is:

\[\begin{split}\log p(x) = -\log{b} \quad \text{for} \quad 0 \leq x < b \\ -\inf \quad \text{otherwise}\end{split}\]
Parameters:

upper (float) – Upper bound of the uniform distribution. Must satisfy 0 < upper <= 1.

Notes

Uses half-open interval [0, upper) to allow exactly e=0 (circular orbits) whilst excluding e=upper (to allow e up to, but not including, 1).

upper
__call__(value: float) float[source]

Calculate log eccentricity uniform prior probability.

Parameters:

value (float) – Parameter value to evaluate

Returns:

Log prior probability

Return type:

float

__repr__() str[source]
class ravest.prior.Normal(mean: float, std: float)[source]

Log of Normal prior distribution.

The Normal probability distribution is:

\[p(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp\left(-\frac{(x - \mu)^2}{2\sigma^2}\right)\]

The log probability is:

\[\log p(x) = -\frac{1}{2}\left(\frac{x - \mu}{\sigma}\right)^2 - \frac{1}{2}\log(2\pi\sigma^2)\]
Parameters:
  • mean (float) – Mean of the Normal distribution.

  • std (float) – Standard deviation of the Normal distribution.

mean
std
_log_norm_const
__call__(value: float) float[source]

Calculate log Normal prior probability.

Parameters:

value (float) – Parameter value to evaluate

Returns:

Log prior probability

Return type:

float

__repr__() str[source]
class ravest.prior.TruncatedNormal(mean: float, std: float, lower: float, upper: float)[source]

Log of properly normalized truncated Normal prior distribution.

The truncated Normal probability distribution is:

\[\begin{split}p(x) = \frac{\phi\left(\frac{x - \mu}{\sigma}\right)}{\sigma \left[\Phi\left(\frac{b - \mu}{\sigma}\right) - \Phi\left(\frac{a - \mu}{\sigma}\right)\right]} \quad \text{for} \quad a \leq x \leq b \\ 0 \quad \text{otherwise}\end{split}\]

where lowercase phi is the standard normal PDF and uppercase Phi is the standard normal CDF.

The log probability is:

\[\begin{split}\log p(x) = \log\phi\left(\frac{x - \mu}{\sigma}\right) - \log\sigma - \log\left[\Phi\left(\frac{b - \mu}{\sigma}\right) - \Phi\left(\frac{a - \mu}{\sigma}\right)\right] \quad \text{for} \quad a \leq x \leq b \\ -\inf \quad \text{otherwise}\end{split}\]

This provides a proper probability distribution that integrates to 1 over [a, b]. This is useful for parameters e.g. that can’t go negative or that are bounded between a lower and upper value, but where you want a more informative prior than a uniform distribution.

Parameters:
  • mean (float) – Mean of the original (untruncated) Normal distribution.

  • std (float) – Standard deviation of the original Normal distribution.

  • lower (float) – Lower bound of the truncation.

  • upper (float) – Upper bound of the truncation.

mean
std
lower
upper
_a
_b
__call__(value: float) float[source]

Calculate log truncated Normal prior probability.

Parameters:

value (float) – Parameter value to evaluate

Returns:

Log prior probability

Return type:

float

__repr__() str[source]
class ravest.prior.HalfNormal(std: float)[source]

Log of half-Normal prior distribution.

The half-Normal probability distribution is:

\[\begin{split}p(x) = \frac{2}{\sigma\sqrt{2\pi}} \exp\left(-\frac{x^2}{2\sigma^2}\right) \quad \text{for} \quad x \geq 0 \\ 0 \quad \text{otherwise}\end{split}\]

The log probability is:

\[\begin{split}\log p(x) = \log(2) - \log(\sigma) - \frac{1}{2}\log(2\pi) - \frac{x^2}{2\sigma^2} \quad \text{for} \quad x \geq 0 \\ -\inf \quad \text{otherwise}\end{split}\]

This is equivalent to a Normal distribution with mean=0 that has been truncated at x=0 to only allow non-negative values (equivalently, the absolute value of a Normal distribution with mean=0).

This can be useful for parameters that must be positive, such as standard deviations, measurement uncertainties, or jitter terms.

Parameters:

std (float) – Standard deviation (sigma) of the half-Normal distribution. Must be > 0.

std
__call__(value: float) float[source]

Calculate log half-Normal prior probability.

Parameters:

value (float) – Parameter value to evaluate

Returns:

Log prior probability

Return type:

float

__repr__() str[source]
class ravest.prior.Rayleigh(scale: float)[source]

Log of Rayleigh prior distribution.

The Rayleigh probability distribution is:

\[\begin{split}p(x) = \frac{x}{\sigma^2} \exp\left(-\frac{x^2}{2\sigma^2}\right) \quad \text{for} \quad x \geq 0 \\ 0 \quad \text{otherwise}\end{split}\]

The log probability is:

\[\begin{split}\log p(x) = \log(x) - 2\log(\sigma) - \frac{x^2}{2\sigma^2} \quad \text{for} \quad x \geq 0 \\ -\inf \quad \text{otherwise}\end{split}\]
Parameters:

scale (float) – Scale parameter (sigma) of the Rayleigh distribution. Must be > 0.

Notes

The Rayleigh prior is zero at x=0 (log prior is -inf). If you expect significant probability mass near zero, consider using another prior such as the HalfNormal or VanEylen19Mixture prior instead.

scale
__call__(value: float) float[source]

Calculate log Rayleigh prior probability.

Parameters:

value (float) – Parameter value to evaluate

Returns:

Log prior probability

Return type:

float

__repr__() str[source]
class ravest.prior.VanEylen19Mixture(sigma_normal: float, sigma_rayleigh: float, f: float)[source]

Log of a Rayleigh & Half-Normal mixture model prior distribution.

The mixture model combines a half-Normal and a Rayleigh distribution, weighted by a mixing fraction f. This model is particularly useful for eccentricity priors in exoplanet systems, where the half-Normal component captures low eccentricities, and the Rayleigh component captures higher eccentricities, as described in Van Eylen et al. (2019).

The mixture probability distribution is:

\[p(x) = (1-f) \cdot p_{\text{HalfNormal}}(x; \sigma_{\text{normal}}) + f \cdot p_{\text{Rayleigh}}(x; \sigma_{\text{rayleigh}})\]

The log probability is:

\[\log p(x) = \log\left[(1-f) \cdot p_{\text{HalfNormal}}(x; \sigma_{\text{normal}}) + f \cdot p_{\text{Rayleigh}}(x; \sigma_{\text{rayleigh}})\right]\]

where: - f = 0 indicates a pure half-Normal distribution (low eccentricities) - f = 1 indicates a pure Rayleigh distribution (higher eccentricities) - 0 < f < 1 represents a mixture of both components

Parameters:
  • sigma_normal (float) – Scale parameter for the half-Normal component. Must be > 0.

  • sigma_rayleigh (float) – Scale parameter for the Rayleigh component. Must be > 0.

  • f (float) – Mixing fraction between 0 and 1. f=0 gives pure half-Normal, f=1 gives pure Rayleigh.

References

Vincent Van Eylen et al 2019 AJ 157 61 (https://doi.org/10.3847/1538-3881/aaf22f)

sigma_normal
sigma_rayleigh
f
__call__(value: float) float[source]

Calculate log mixture prior probability.

Parameters:

value (float) – Parameter value to evaluate

Returns:

Log prior probability

Return type:

float

__repr__() str[source]
class ravest.prior.Beta(a: float, b: float)[source]

Log of Beta prior distribution, for parameter x where 0 <= x <= 1.

The Beta probability distribution is:

\[\begin{split}p(x) = \frac{x^{a-1}(1-x)^{b-1}}{B(a,b)} \quad \text{for} \quad 0 \leq x \leq 1 \\ 0 \quad \text{otherwise}\end{split}\]

where B(a,b) is the beta function.

The log probability is:

\[\begin{split}\log p(x) = (a - 1)\log(x) + (b - 1)\log(1-x) - \log B(a,b) \quad \text{for} \quad 0 \leq x \leq 1 \\ -\inf \quad \text{otherwise}\end{split}\]
Parameters:
  • a (float) – Shape parameter a of the Beta distribution. Must be > 0.

  • b (float) – Shape parameter b of the Beta distribution. Must be > 0.

Notes

The Beta distribution’s behaviour at the boundaries depends on the shape parameters. Consider the shape of your Beta distribution if you expect to have significant probability mass near 0 or 1, where probability may be 0 or infinite (depending on the shape parameters).

a
b
_log_beta
__call__(value: float) float[source]

Calculate log Beta prior probability.

Parameters:

value (float) – Parameter value to evaluate

Returns:

Log prior probability

Return type:

float

__repr__() str[source]