pyselfi.power_spectrum.selfi module¶
SELFI for power spectrum inference: main class.
- class pyselfi.power_spectrum.selfi.power_spectrum_selfi(fname, pool_prefix, pool_suffix, prior, blackbox, theta_0, Ne, Ns, Delta_theta, phi_obs)[source]¶
Bases:
selfi
Main class for power spectrum inference with SELFI. Child of the main class of the SELFI code.
- loglikelihood_hyperparams(theta_fiducial, Nbin_opt_min, Nbin_opt_max, theta_norm, k_corr)[source]¶
Returns the log pdf of the likelihood for hyperparameters theta_norm and k_corr. See equation (27) in Leclercq et al. (2019).
- Parameters
theta_fiducial (array, double, dimension=S) – fiducial point in parameter space to optimize the prior
Nbin_opt_min (int) – minimum index in k_s considered for optimization
Nbin_opt_max (int) – maximum index in k_s considered for optimization
theta_norm (double) – theta_norm value where to evaluate the likelihood
k_corr (double) – k_corr value where to evaluate the likelihood
- Returns
logpdf – log pdf of the likelihood at the evaluation point
- Return type
double
- logposterior_hyperparameters(theta_fiducial, Nbin_opt_min, Nbin_opt_max, theta_norm, k_corr, theta_norm_mean=0.2, theta_norm_std=0.3, k_corr_mean=0.025, k_corr_std=0.015)[source]¶
Returns the log pdf of the unnormalized posterior for hyperparameters theta_norm and k_corr (logprior_hyperparameters + loglikelihood_hyperparams).
- Parameters
theta_fiducial (array, double, dimension=S) – fiducial point in parameter space to optimize the prior
Nbin_opt_min (int) – minimum index in k_s considered for optimization
Nbin_opt_max (int) – maximum index in k_s considered for optimization
theta_norm (double) – theta_norm value where to evaluate the likelihood
k_corr (double) – k_corr value where to evaluate the likelihood
theta_norm_mean (double, optional, default=0.2) – mean of the Gaussian prior on theta_norm
theta_norm_std (double, optional, default=0.3) – standard deviations of the Gaussian prior on theta_norm
k_corr_mean (double, optional, default=0.025) – mean of the Gaussian prior on k_corr
k_corr_std (double, optional, default=0.015) – standard deviations of the Gaussian prior on k_corr
- Returns
logpdf – log pdf of the unnormalized posterior at the evaluation point
- Return type
double
- logprior_hyperparameters(theta_norm, theta_norm_mean, theta_norm_std, k_corr, k_corr_mean, k_corr_std)[source]¶
Returns the log pdf of the Gaussian prior for hyperparameters theta_norm and k_corr.
- Parameters
theta_norm (double) – theta_norm value where to evaluate the prior
theta_norm_mean (double) – mean of the Gaussian prior on theta_norm
theta_norm_std (double) – standard deviations of the Gaussian prior on theta_norm
k_corr (double) – k_corr value where to evaluate the prior
k_corr_mean (double) – mean of the Gaussian prior on k_corr
k_corr_std (double) – standard deviations of the Gaussian prior on k_corr
- Returns
logpdf – log pdf of the Gaussian prior at the evaluation point
- Return type
double
- optimize_prior(theta_fiducial, k_opt_min, k_opt_max, x0=None, theta_norm_min=1e-05, theta_norm_max=5.0, theta_norm_mean=0.2, theta_norm_std=0.3, k_corr_min=0.005, k_corr_max=0.05, k_corr_mean=0.025, k_corr_std=0.015, method='L-BFGS-B', options={'disp': True, 'eps': 1e-06, 'ftol': 1e-20, 'gtol': 1e-20, 'maxiter': 50})[source]¶
Optimizes the SELFI prior. See section II.E. in Leclercq et al. (2019).
- Parameters
theta_fiducial (array, double, dimension=S) – fiducial point in parameter space to optimize the prior
k_opt_min (double) – minimum wavenumber to be used in prior optimization
k_opt_max (double) – maximum wavenumber to be used in prior optimization
x0 (array, double, dimension=2, optional, default=(prior.theta_norm,prior.k_corr))) – starting point in parameter space
theta_norm_min (double, optional, default=1e-5) – boundary in parameter space
theta_norm_max (double, optional, default=5.) – boundary in parameter space
theta_norm_mean (double, optional, default=0.2) – mean of the Gaussian prior on theta_norm
theta_norm_std (double, optional, default=0.3) – standard deviations of the Gaussian prior on theta_norm
k_corr_min (double, optional, default=0.005) – boundary in parameter space
k_corr_max (double, optional, default=0.05) – boundary in parameter space
k_corr_mean (double, optional, default=0.025) – mean of the Gaussian prior on k_corr
k_corr_std (double, optional, default=0.015) – standard deviations of the Gaussian prior on k_corr
method (
str
, optional, default=’L-BFGS-B’) – optimization method. See documentation of scipy.optimize.minimizeoptions (dictionary, optional, default={‘maxiter’:50, ‘ftol’:1e-20, ‘gtol’:1e-20, ‘eps’:1e-6, ‘disp’:True}) – optimization options. See documentation of scipy.optimize.minimize
- restrict_posterior(Nbin_min, Nbin_max)[source]¶
Restricts the SELFI posterior to some range of scales.
- Parameters
Nbin_min (int) – minimal index in k_s to be used
Nbin_max (int) – maximal index in k_s to be used
- Returns
theta_mean (array, double, dimension=S’) – restricted posterior mean
theta_covariance (array, double, dimension=(S’,S’)) – restricted posterior covariance
theta_icov (array, double, dimension=(S’,S’)) – restricted inverse posterior covariance where S’=Nbin_max-Nbin_min
- restrict_prior(Nbin_min, Nbin_max)[source]¶
Restricts the SELFI prior to some range of scales.
- Parameters
Nbin_min (int) – minimal index in k_s to be used
Nbin_max (int) – maximal index in k_s to be used
- Returns
theta_mean (array, double, dimension=S’) – restricted prior mean
theta_covariance (array, double, dimension=(S’,S’)) – restricted prior covariance
theta_icov (array, double, dimension=(S’,S’)) – restricted inverse prior covariance where S’=Nbin_max-Nbin_min