Particle sampling algorithms
Particle sampling algorithms are a class of Monte Carlo methods that approximate a target distribution through a set of "particles" or points in the parameter space which are weighted or evolved according to some update rule. The stationary distribution of the particles after some number of updates then typically corresponds to the target. In the setting of Bayesian inference, the target distribution is the posterior.
The simplest form of particle method is importance sampling which reweights samples from a so-called proposal distribution. If the proposal is taken to be the prior and the weighting function is simply the likelihood, the resulting weighted samples will approximately follow the posterior distribution. This is implemented in SimulationBasedInference
as the "ensemble importance sampling" (EnIS) algorithm:
SimulationBasedInference.EnIS
— TypeEnIS
Basic ensemble importance sampling (EnIS) inference algorithm. Also sometimes referred to as the "particle batch smoother" (PBS) or "generalized likelihood uncertainty estimation" (GLUE) depending on the context.
where "ensemble" here refers to the collection of particles used for the Monte Carlo approximation.
Naive importance sampling algorithms tend to be very inefficient when applied to high-dimensional or highly nonlinear systems.
For fully Gaussian problems (i.e., Gaussian prior and likelihood), Kalman-type methods are a much more efficient alternative.
SimulationBasedInference
currently provides two ensemble Kalman-type algorithms; the first is the Ensmeble Kalman Sampler (EKS; Garbuno-Inigo et al. 2020):
SimulationBasedInference.EKS
— TypeEKS <: EnsembleInferenceAlgorithm
Represents a proxy for the Ensemble Kalman Sampler (Garbuno-Inigo et al. 2020) implementation provided by EnsembleKalmanProcesses
.
and the second is the Ensemble Smoother with Multiple Data Assimilation (ES-MDA; Emerick and Reynolds 2013):
SimulationBasedInference.ESMDA
— TypeESMDA <: EnsembleInferenceAlgorithm
Implementation of the ensemble-smother multiple data assimilation algorithm of Emerick et al. 2013.
Emerick, Alexandre A., and Albert C. Reynolds. "Ensemble smoother with multiple data assimilation." Computers & Geosciences 55 (2013): 3-15.
Ensemble interface methods
All EnsembleInferenceAlgorithm
s implement the following method interface:
SimulationBasedInference.get_ensemble
— Methodget_ensemble(state::EnsembleState)
Retrieves the current ensemble matrix from the given EnsembleState
. Must be implemented for each ensemble algorithm state type.
SimulationBasedInference.isiterative
— Methodisiterative(alg::EnsembleInferenceAlgorithm)
Returns true
if the given ensemble inference algorithm is iterative, false
otherwise. Default implementation returns false
(non-iterative).
SimulationBasedInference.hasconverged
— Methodhasconverged(alg::EnsembleInferenceAlgorithm, state::EnsembleState)
Should return true
when alg
at the current state
has converged, false
otherwise. Must be implemented for each ensemble algorithm state type.
SimulationBasedInference.initialstate
— Methodinitialstate(
alg::EnsembleInferenceAlgorithm,
ens::AbstractMatrix,
obs::AbstractVector,
obscov::AbstractMatrix;
rng::AbstractRNG=Random.GLOBAL_RNG
)
Constructs the initial ensemble state for the given algorithm and observations.
SimulationBasedInference.ensemblestep!
— Methodensemblestep!(solver::EnsembleSolver{algType}) where {algType}
Executes a single ensemble step (forward solve + update) for the given algorithm type. Must be implemented by all ensemble algorithm implementations.
SimulationBasedInference.finalize!
— Methodfinalize!(solver::EnsembleSolver)
Finalizes the solver state after iteration has completed. Default implementation runs ensemble_solve
on the current ensemble state and pushes the results to sol.outputs
.
EnsembleState
is an abstract type which must be subtyped by each ensemble algorithm implementation.
SimulationBasedInference.EnsembleState
— TypeEnsembleState
Base type for ensemble inference algorithm state implementations.
EnsembleSolver
acts as a container for all of the common components shared by all ensemble algorithms.
SimulationBasedInference.EnsembleSolver
— TypeEnsembleSolver{algType,probType,ensalgType,stateType<:EnsembleState,kwargTypes}
Generic implementation of an iterative solver for any ensemble-based algorithm. Uses the SciML EnsembleProblem
interface to automatically parallelize forward runs over the ensemble.
Utility methods
The following utility methods are also provided
SimulationBasedInference.get_transformed_ensemble
— Methodget_transformed_ensemble(sol::SimulatorInferenceSolution{<:EnsembleInferenceAlgorithm}, iter::Int=-1)
Fetches the transformed ensemble from the given solution object. For iterative algorithms, the optinal argument iter
may be provided, which then retrieves the ensemble at the given iteration.
SimulationBasedInference.get_observables
— Methodget_observables(sol::SimulatorInferenceSolution{<:EnsembleInferenceAlgorithm}, iter::Int=-1)
Returns a NamedTuple
of concatenated observables at iteration iter
.
Internally, the algorithms use ensemble_solve
to construct and solve an EnsembleProblem
over the parameter ensemble.
SimulationBasedInference.ensemble_solve
— Methodensemble_solve(
ens::AbstractMatrix,
initial_prob::SciMLBase.AbstractSciMLProblem,
ensalg::SciMLBase.BasicEnsembleAlgorithm,
dealg::Union{Nothing,SciMLBase.AbstractSciMLAlgorithm},
param_map;
iter::Integer=1,
prob_func,
output_func,
pred_func,
solve_kwargs...
)
Performs a single step/iteration for the given ensemble and returns a named tuple (; pred, sol)
where sol
are the full ensemble forward solutions and pred
is the prediction matrix produced by pred_func
.