Accept-reject sampler

In addition to sampling each model parameter independently, the module provides support for sampling particles according to arbitrary target distributions, using an accept-reject sampler. Proposals will be drawn from the model prior distribution., target, seed, notify_fn=None)

Select particles according to a target distribution. Proposals will be drawn from the model prior distribution.

  • instance – The simulation instance.

  • target – The target distribution.

  • seed – The PRNG seed used for accepting particles.

  • notify_fn – An optional function that is notified of each acceptance loop, and should accept two arguments: the number of particles and the number of accepted particles.


The initial state vector for each accepted particle.

Return type



The instance should not be reused after calling this function. To prevent this from happening, the instance settings will be deleted.

# Save the accepted particles to disk.
vec =, target, seed)
sampled_values = vec[column_names]
header = ' '.join(column_names)
np.savetxt(out_file, sampled_values, header=header, comments='')

Any target distribution for which a probability density can be defined can be used with this sampler:


The base class for target particle distributions.

Two target distributions are provided by this module.

The TargetAny distribution accepts all particles with equal likelihood, for the case where the proposal distribution is identical to the desired target distribution:


A distribution that accepts all proposals with equal likelihood.

The TargetPeakMVN distribution is a multivariate normal distribution for the peak timing and size, as defined by previously-observed peaks:

class, peak_times)

A multivariate normal distribution for the peak timing and size.

  • peak_sizes – An array of previously-observed peak sizes.

  • peak_time – An array of previously-observed peak times.