pyselfi.power_spectrum.prior module¶
Routines related to the SELFI power spectrum prior.
- class pyselfi.power_spectrum.prior.power_spectrum_prior(k_s, theta_0, theta_norm, k_corr, alpha_cv, log_kmodes=False)[source]¶
Bases:
object
This class represents the SELFI power spectrum prior. See equations (20)-(23) in Leclercq et al. (2019) for expressions.
- Variables
k_s (array, double, dimension=S) – array of support wavenumbers
theta_0 (array, double, dimension=S) – prior mean
theta_norm (double) – overall amplitude of the prior covariance matrix
k_corr (double) – wavenumber of the length scale of prior correlations
alpha_cv (double) – strength of cosmic variance
log_kmodes (bool, optional, default=False) – take RBF in log(k) instead of k?
- Nbin_max(k_max)[source]¶
Finds the index of the maximal wavenumber given k_max.
- Parameters
k_max (double) – maximal wavenumber
- Returns
Nbin_max – maximal index such that k_s[Nbin_max] <= k_max
- Return type
int
- Nbin_min(k_min)[source]¶
Finds the index of the minimal wavenumber given k_min.
- Parameters
k_min (double) – minimal wavenumber
- Returns
Nbin_min – minimal index such that k_s[Nbin_min] >= k_min
- Return type
int
- _get_cosmic_variance()[source]¶
Gets the cosmic variance part of the prior covariance matrix, \(\textbf{u}\textbf{u}^\intercal\). See equations (21)-(22) in Leclercq et al. (2019).
- Returns
V – cosmic variance matrix
- Return type
array, double, dimension=(S,S)
- _get_covariance()[source]¶
Gets the full prior covariance matrix. See equation (22) in Leclercq et al. (2019).
- Returns
S – covariance matrix of the prior
- Return type
array, double, dimension=(S,S)
- _get_inverse_covariance()[source]¶
Gets the inverse covariance matrix.
- Returns
inv_S – inverse covariance matrix of the prior
- Return type
array, double, dimension=(S,S)
- _get_rbf()[source]¶
Gets the radial basis function (RBF) part of the prior covariance matrix. See equation (20) in Leclercq et al. (2019).
- Returns
K – RBF kernel
- Return type
array, double, dimension=(S,S)
- property gamma¶
Defined by \(\gamma \equiv 1/(2 k_\mathrm{corr}^2)\)
- Type
double
- property gamma_log¶
Defined by \(\gamma_\mathrm{log} \equiv 1/(2 \log k_\mathrm{corr}^2)\)
- Type
double
- classmethod load(fname)[source]¶
Loads the prior from an input file.
- Parameters
fname (
str
) – input filename- Returns
prior – loaded prior object
- Return type
prior
- logpdf(theta, theta_mean, theta_covariance, theta_icov)[source]¶
Returns the log prior probability at a given point in parameter space. See equation (23) in Leclercq et al. (2019).
- Parameters
theta (array, double, dimension=S) – evaluation point in parameter space
theta_mean (array, double, dimension=S) – prior mean
theta_covariance (array, double, dimension=(S,S)) – prior covariance
theta_icov (array, double, dimension=(S,S)) – inverse prior covariance
- Returns
logpdf – log prior probability
- Return type
double