ABC-SMC sampler¶
- class pints.ABCSMC(log_prior, perturbation_kernel=None, nr_samples=100, error_schedule=[1])[source]¶
Implements the ABC-SMC algorithm as described in [1]. This algorithm is also referred to as ABC Population Monte Carlo (ABC PMC) [2].
In this algorithm there are going to be several rounds of ABC, each with a different proposal distribution. For each round, we try to obtain
nr_samples
samples at once. In order to transition between each set ofnr_samples
, we have intermediate distributions \(p_t(\theta)\) from which we sample the candidates for the new distribution. In particular, \(p_0(\theta)\) is the prior and for \(t>0\) \(p_t(\theta)\) proposes sample \(\theta^{t-1}_i\) with weight \(\w^{t-1}_i\) (which is computed at the end of the iteration). In particular, at each iteration of the algorithm the following steps occur:\[\begin{split}\begin{align} & \theta^* \sim p_{t-1}(\theta) \textrm{, i.e. sample parameters from previous intermediate distribution} \\ & \theta^{**} \sim K(\theta|\theta^{*}), \textrm{i.e. perturb } \theta^{*} \textrm{ to obtain to new point } x \sim p(x|\theta^{**})\textrm{, i.e. sample data from sampling distribution} \\ & \textrm{if } s(x) < \textrm{threshold}_(t), \theta^* \textrm{ add to list of samples[t]} \end{align}\end{split}\]After we have obtained
nr_samples
samples,t
is advanced, and weights are calculated forsamples[t-1]
. At the last error threshold, samples are returned whenever they are accepted.- Parameters:
log_prior – A
pints.LogPrior
that specifies the logarithmic prior for the set of parameters that will be sampled.perturbation_kernel – A
pints.LogPrior
used for perturbing the particles sampled from the previous generation. By default a multivariate Gaussian distribution is used with mean I and 0.001 * I as covariance.nr_samples – The number of samples requested for intermediate distributions.
error_schedule – The schedule of error threshold distance for all distributions.
References
- ask(n_samples)[source]¶
See
ABCSampler.ask()
.
- n_hyper_parameters()¶
Returns the number of hyper-parameters for this method (see
TunableMethod
).
- set_hyper_parameters(x)¶
Sets the hyper-parameters for the method with the given vector of values (see
TunableMethod
).- Parameters:
x – An array of length
n_hyper_parameters
used to set the hyper-parameters.
- set_intermediate_size(n)[source]¶
Sets the size of the intermediate distributions, after we find n acceptable samples then we will progress to the next threshold values in the schedule.
- set_perturbation_kernel(perturbation_kernel)[source]¶
Sets the perturbation kernel used for perturbing particles that are sampled from the previous generations. It must implement the
pints.LogPrior
class.
- set_threshold_schedule(schedule)[source]¶
Sets a schedule for the threshold error distance that determines if a sample is accepted (if error < threshold). Schedule should be a list of float values.
- tell(fx)[source]¶
See
ABCSampler.tell()
.