abcpmc Package¶
sampler Module¶
-
class
abcpmc.sampler.Sampler(N, Y, postfn, dist, threads=1, pool=None)[source]¶ ABC population monte carlo sampler
Parameters: - N – number of particles
- Y – observed data set
- postfn – model function (a callable), which creates a new dataset x for a given theta
- dist – distance function rho(X, Y) (a callable)
- threads – (optional) number of threads. If >1 and no pool is given <threads> multiprocesses will be started
- pool – (optional) a pool instance which has a <map> function
-
particle_proposal_cls¶ alias of
ParticleProposal
-
sample(prior, eps_proposal)[source]¶ Launches the sampling process. Yields the intermediate results per iteration.
Parameters: - prior – instance of a prior definition (or an other callable) see
sampler.GaussianPrior - eps_proposal – an instance of a threshold proposal (or an other callable) see
sampler.ConstEps
Yields pool: yields a namedtuple representing the values of one iteration
- prior – instance of a prior definition (or an other callable) see
-
class
abcpmc.sampler.GaussianPrior(mu, sigma)[source]¶ Normal gaussian prior
Parameters: - mu – scalar or vector of means
- sigma – scalar variance or covariance matrix
-
class
abcpmc.sampler.TophatPrior(min, max)[source]¶ Tophat prior
Parameters: - min – scalar or array of min values
- max – scalar or array of max values
-
class
abcpmc.sampler.ParticleProposal(sampler, eps, pool, kwargs)[source]¶ Creates new particles using twice the weighted covariance matrix (Beaumont et al. 2009)
-
class
abcpmc.sampler.OLCMParticleProposal(sampler, eps, pool, kwargs)[source]¶ Bases:
abcpmc.sampler.ParticleProposalCreates new particles using an optimal loacl covariance matrix (Fillipi et al. 2012)
-
class
abcpmc.sampler.KNNParticleProposal(sampler, eps, pool, kwargs)[source]¶ Bases:
abcpmc.sampler.ParticleProposalCreates new particles using a covariance matrix from the K-nearest neighbours (Fillipi et al. 2012) Set k as key-word arguement in abcpmc.Sampler.particle_proposal_kwargs
-
abcpmc.sampler.weighted_cov(values, weights)[source]¶ Computes a weighted covariance matrix
Parameters: - values – the array of values
- weights – array of weights for each entry of the values
Returns sigma: the weighted covariance matrix
-
abcpmc.sampler.weighted_avg_and_std(values, weights, axis=None)[source]¶ Return the weighted avg and standard deviation.
Parameters: - values – Array with the values
- weights – Array with the same shape as values containing the weights
- axis – (optional) the axis to be used for the computation
Returns avg, sigma: weighted average and standard deviation
threshold Module¶
Various different threshold implementations
Created on Jan 19, 2015
author: jakeret
-
class
abcpmc.threshold.ConstEps(T, eps)[source]¶ Bases:
abcpmc.threshold.EpsProposalConstant threshold. Can be used to apply alpha-percentile threshold decrease :param eps: epsilon value
-
class
abcpmc.threshold.ExponentialConstEps(max, min, T1, T2)[source]¶ Bases:
abcpmc.threshold.EpsProposal
-
class
abcpmc.threshold.ExponentialEps(T, max, min)[source]¶ Bases:
abcpmc.threshold.EpsProposalExponentially decreasing threshold
Parameters: - max – epsilon at t=0
- min – epsilon at t=T
- T – number of iterations
-
class
abcpmc.threshold.LinearConstEps(max, min, T1, T2)[source]¶ Bases:
abcpmc.threshold.EpsProposalLinearly decreasing threshold until T1, then constant until T2
Parameters: - max – epsilon at t=0
- min – epsilon at t=T
- T1 – number of iterations for decrease
- T2 – number of iterations for constant behavior
-
class
abcpmc.threshold.LinearEps(T, max, min)[source]¶ Bases:
abcpmc.threshold.EpsProposalLinearly decreasing threshold
Parameters: - max – epsilon at t=0
- min – epsilon at t=T
- T – number of iterations
-
class
abcpmc.threshold.ListEps(T, eps_vals)[source]¶ Bases:
abcpmc.threshold.EpsProposal