Posterior¶
Given a Prior and a data set
\(\mathcal{N}=\{x_i\,:\,i=1..n\}\), pybalonor comes with the
Posterior
class that allows to evaluate the posterior
predictive distribution, its quantiles, and the posterior distribution of the
distribution mean.
The formulae evaluated for the posterior ar given in Scientific Background, and [Z2023] details how these equations are evaluated.
Posterior
¶
- class Posterior(sample, prior, n_chebyshev=100)¶
The posterior distribution of the log-normal distribution parameters given a sample and prior.
- Parameters
sample (array_like) – The sample for which to compute the posterior distribution.
prior (FlatPrior) – The prior distribution.
n_chebyshev (int, optional) – The number of Chebyshev points used in the barycentric Lagrange interpolation of the posterior predictive CDF for the posterior predictive quantiles. Defaults to 100.
- density(l0, l1)¶
Posterior probability density.
- Parameters
l0 (array_like) – Vector of parameters \(l_0\) at which to evaluate the posterior distribution.
l1 (array_like) – Vector of parameters \(l_1\) at which to evaluate the posterior distribution.
- Returns
density – NumPy array of the posterior density evaluated at
l0
andl1
.- Return type
array_like
- log_density(l0, l1)¶
Logarithm of the posterior probability density.
- Parameters
l0 (array_like) – Vector of parameters \(l_0\) at which to evaluate the posterior distribution.
l1 (array_like) – Vector of parameters \(l_1\) at which to evaluate the posterior distribution.
- Returns
density – NumPy array of the logarithm of the posterior density evaluated at
l0
andl1
.- Return type
array_like
- log_mean_pdf(mu)¶
Logarithm of the posterior density of the distribution mean \(\mu\).
- Parameters
mu (array_like) – Vector of the distribution mean \(\mu\) at which to evaluate its posterior distribution.
- Returns
log_pdf – NumPy array of the logarithm of the posterior density evaluated at
mu
.- Return type
array_like
- log_predictive_pdf(x)¶
Logarithm of the posterior predictive density.
- Parameters
x (array_like) – Vector of \(x\) at which to evaluate the posterior predictive distribution.
- Returns
pdf – NumPy array of the logarithm of the posterior predictive density evaluated at
x
.- Return type
array_like
- mean_pdf(mu)¶
Posterior density of the distribution mean \(\mu\).
- Parameters
mu (array_like) – Vector of the distribution mean \(\mu\) at which to evaluate its posterior distribution.
- Returns
pdf – NumPy array of the posterior density evaluated at
mu
.- Return type
array_like
- predictive_ccdf(x)¶
Posterior predictive complementary distribution function (or survivor function).
- Parameters
x (array_like) – Vector of \(x\) at which to evaluate the posterior predictive distribution.
- Returns
ccdf – NumPy array of the complementary cumulative posterior predictive distribution evaluated at
x
.- Return type
array_like
- predictive_cdf(x)¶
Posterior predictive cumulative distribution function.
- Parameters
x (array_like) – Vector of \(x\) at which to evaluate the posterior predictive distribution.
- Returns
cdf – NumPy array of the cumulative posterior predictive distribution evaluated at
x
.- Return type
array_like
- predictive_pdf(x)¶
Posterior predictive density.
- Parameters
x (array_like) – Vector of \(x\) at which to evaluate the posterior predictive distribution.
- Returns
pdf – NumPy array of the posterior predictive density evaluated at
x
.- Return type
array_like
- predictive_quantiles(q)¶
Quantiles of the posterior predictive distribution.
- Parameters
q (array_like) – Vector of quantiles \(q\) of the posterior predictive distribution to compute.
- Returns
x – NumPy array of the arguments \(x\) of the posterior predictive distribution corresponding to the quantiles \(q\).
- Return type
array_like
- predictive_tail_quantiles(q)¶
Tail quantiles of the posterior predictive distribution (or quantiles of the complementary posterior predictive distribution).
- Parameters
q (array_like) – Vector of quantiles \(q\) of the complementary cumulative posterior predictive distribution to compute.
- Returns
x – NumPy array of the arguments \(x\) of the posterior predictive distribution corresponding to the quantiles \(1-q\).
- Return type
array_like