pyselfi.selfi module¶
Main class of the SELFI code.
- class pyselfi.selfi.selfi(fname, pool_prefix, pool_suffix, prior, blackbox, theta_0, Ne, Ns, Delta_theta, phi_obs)[source]¶
Bases:
object
Main class of the SELFI code.
- Variables
fname (
str
) – name and address of the selfi output file on diskpool_prefix (
str
) – address and prefix of the simulation poolspool_suffix (
str
) – suffix of the simulation poolsprior (
prior
) – the prior, defined as explained in the SELFI documentationblackbox (
blackbox
) – the blackbox simulator, defined as explained in the SELFI documentationtheta_0 (array, double, dimension=S) – expansion point in parameter space
Ne (int) – number of simulations at the expansion point, to compute the covariance matrix
Ns (int) – number of simulations per expansion direction in parameter space. (Ne may be larger than Ns, in which case only the first Ns simulations at the expansion point are used to compute the gradient)
Delta_theta (double) – step size for finite differencing to compute the blackbox gradient in parameter space
phi_obs (array, double, dimension=P) – the vector of observed data
- compute_likelihood(Ns=None, h=None)[source]¶
Computes the likelihood, assuming that the necessary simulations are available.
- Parameters
Ns (int, optional, default=class value) – number of simulations per expansion direction in parameter space
h (double, optional, default=class value) – step size for finite differencing to compute the blackbox gradient in parameter space
- compute_posterior()[source]¶
Computes the SELFI posterior, assuming that the prior and likelihood have been computed.
- run_simulations(d=None, pool_prefix=None, pool_suffix=None, Ne=None, Ns=None, h=None)[source]¶
Runs the necessary simulations for the likelihood.
- Parameters
d (int or array of int, optional, default=None) – directions in parameter space, from 0 to S. If set to None, all simulations are run or loaded
pool_prefix (
str
, optional, default=class value) – address and prefix of the filenames for simulation poolspool_suffix (
str
, optional, default=class value) – suffix of the filenames for simulation poolsNe (int, optional, default=class value) – number of simulations at the expansion point, to compute the covariance matrix.
Ns (int, optional, default=class value) – number of simulations per expansion direction in parameter space
h (double, optional, default=class value) – step size for finite differencing to compute the blackbox gradient in parameter space