pyselfi.posterior module¶
Routines related to the SELFI posterior.
- class pyselfi.posterior.posterior(theta_0, prior_covariance, inv_prior_covariance, f_0, C_0, inv_C_0, grad_f, phi_obs)[source]¶
Bases:
object
This class represents the SELFI posterior. See equations (25) and (26) in Leclercq et al. (2019) for expressions.
- Variables
theta_0 (array, double, dimension=S) – prior mean and expansion point
prior_covariance (array, double, dimension=(S,S)) – prior covariance matrix
inv_prior_covariance (array, double, dimension=(S,S)) – inverse prior covariance matrix
f_0 (array, double, dimension=P) – mean blackbox at the expansion point
C_0 (array, double, dimension=(P,P)) – covariance matrix of summaries at the expansion point
inv_C_0 (array, double, dimension=(P,P)) – inverse covariance matrix of summaries at the expansion point
grad_f (array, double, dimension=(S,P)) – gradient of the blackbox at the expansion point
phi_obs (array, double, dimension=P) – observed summaries vector
- _get_posterior_covariance()[source]¶
Gets the posterior covariance. See equation (26) in Leclercq et al. (2019).
- Returns
Gamma – posterior covariance matrix
- Return type
array, double, dimension=(S,S)
- _get_posterior_covariance_alt()[source]¶
Gets the posterior covariance. See equation (26) in Leclercq et al. (2019). Alternative algebra: can be used if numerically more stable.
- Returns
Gamma – posterior covariance matrix
- Return type
array, double, dimension=(S,S)
- _get_posterior_mean()[source]¶
Gets the posterior mean. See equation (25) in Leclercq et al. (2019).
- Returns
gamma – posterior mean
- Return type
array, double, dimension=S
- _get_posterior_mean_alt()[source]¶
Gets the posterior mean. See equation (25) in Leclercq et al. (2019). Alternative algebra: can be used if numerically more stable.
- Returns
gamma – posterior mean
- Return type
array, double, dimension=S
- classmethod load(fname)[source]¶
Loads the posterior from an input file.
- Parameters
fname (
str
) – input filename- Returns
posterior – loaded posterior object
- Return type
- logpdf(theta, theta_mean, theta_covariance, theta_icov)[source]¶
Returns the log posterior probability at a given point in parameter space. See equation (24) in Leclercq et al. (2019).
- Parameters
theta (array, double, dimension=S) – evaluation point in parameter space
theta_mean (array, double, dimension=S) – posterior mean
theta_covariance (array, double, dimension=(S,S)) – posterior covariance
theta_icov (array, double, dimension=(S,S)) – inverse posterior covariance
- Returns
logpdf – log posterior probability
- Return type
double