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 disk

  • pool_prefix (str) – address and prefix of the simulation pools

  • pool_suffix (str) – suffix of the simulation pools

  • prior (prior) – the prior, defined as explained in the SELFI documentation

  • blackbox (blackbox) – the blackbox simulator, defined as explained in the SELFI documentation

  • theta_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.

compute_prior()[source]

Computes the prior.

load_likelihood()[source]

Loads the likelihood from the SELFI output file.

load_posterior()[source]

Loads the posterior from the SELFI output file.

load_prior()[source]

Loads the prior from the SELFI output file.

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 pools

  • pool_suffix (str, optional, default=class value) – suffix of the filenames for simulation pools

  • Ne (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

save_likelihood()[source]

Saves the likelihood to the SELFI output file.

save_posterior()[source]

Saves the posterior to the SELFI output file.

save_prior()[source]

Saves the prior to the SELFI output file.