ABC sampler base class¶
- class pints.ABCSampler[source]¶
Abstract base class for ABC methods. All ABC samplers implement the
pints.Loggable
andpints.TunableMethod
interfaces.- 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.
- 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
ABCController
object. 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
LogPrior
function from which parameter values are sampledmethod – The class of
ABCSampler
to use. If no method is specified,RejectionABC
is 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
None
if it is not. Seeset_max_iterations()
.
- parallel()[source]¶
Returns the number of parallel worker processes this routine will be run on, or
False
if 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
iters
iterations.warm_up – A log message will be shown every iteration, for the first
warm_up
iterations.
- set_log_to_file(filename=None, csv=False)[source]¶
Enables progress logging to file when a filename is passed in, disables it if
filename
isFalse
orNone
.The argument
csv
can be set toTrue
to 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 settingparallel
to an integer greater than 0. Parallelisation can be disabled by settingparallel
to0
orFalse
.