ABC sampler base class¶
- class pints.ABCSampler[source]¶
Abstract base class for ABC methods. All ABC samplers implement the
pints.Loggableandpints.TunableMethodinterfaces.- 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_parametersused to set the hyper-parameters.
- class pints.ABCController(error_measure, log_prior, method=None)[source]¶
Samples from a
pints.LogPrior.Properties related to the number of iterations, parallelisation, threshold, and number of parameters to sample can be set directly on the
ABCControllerobject. Afterwards the ABC routine can be run.- Parameters:
error_measure – An error measure to evaluate on a problem, given a forward model, simulated and observed data, and times
log_prior – A
LogPriorfunction from which parameter values are sampledmethod – The class of
ABCSamplerto use. If no method is specified,RejectionABCis used.
Example
- ::
abc = pints.ABCController(error_measure, log_prior) abc.set_max_iterations(1000) posterior_estimate = abc.run()
- max_iterations()[source]¶
Returns the maximum iterations if this stopping criterion is set, or
Noneif it is not. Seeset_max_iterations().
- parallel()[source]¶
Returns the number of parallel worker processes this routine will be run on, or
Falseif parallelisation is disabled.
- set_log_interval(iters=20, warm_up=3)[source]¶
Changes the frequency with which messages are logged.
- Parameters:
iters – A log message will be shown every
itersiterations.warm_up – A log message will be shown every iteration, for the first
warm_upiterations.
- set_log_to_file(filename=None, csv=False)[source]¶
Enables progress logging to file when a filename is passed in, disables it if
filenameisFalseorNone.The argument
csvcan be set toTrueto write the file in comma separated value (CSV) format. By default, the file contents will be similar to the output on screen.
- set_max_iterations(iterations=10000)[source]¶
Adds a stopping criterion, allowing the routine to halt after the given number of
iterations.This criterion is enabled by default. To disable it, use
set_max_iterations(None).
- set_parallel(parallel=False)[source]¶
Enables/disables parallel evaluation.
If
parallel=True, the method will run using a number of worker processes equal to the detected cpu core count. The number of workers can be set explicitly by settingparallelto an integer greater than 0. Parallelisation can be disabled by settingparallelto0orFalse.