ConjugateApprox#
- class cuqi.experimental.mcmc.ConjugateApprox(target=None, initial_point=None, callback=None)#
Approximate Conjugate sampler
Sampler for sampling a posterior distribution where the likelihood and prior can be approximated by a conjugate pair.
Currently supported pairs are: - (LMRF, Gamma): Approximated by (Gaussian, Gamma) where Gamma is defined on the inverse of the scale parameter of the LMRF distribution.
Gamma distribution must be univariate.
LMRF likelihood must have zero mean.
For more details on conjugacy see
Conjugate
.- __init__(target=None, initial_point=None, callback=None)#
Initializer for abstract base class for all samplers.
Any subclassing samplers should simply store input parameters as part of the __init__ method.
The actual initialization of the sampler should be done in the _initialize method.
- Parameters:
target (cuqi.density.Density) – The target density.
initial_point (array-like, optional) – The initial point for the sampler. If not given, the sampler will choose an initial point.
callback (callable, optional) – A function that will be called after each sample is drawn. The function should take two arguments: the sample and the index of the sample. The sample is a 1D numpy array and the index is an integer. The callback function is useful for monitoring the sampler during sampling.
Methods
__init__
([target, initial_point, callback])Initializer for abstract base class for all samplers.
Return the history of the sampler.
Return the samples.
Return the state of the sampler.
Initialize the sampler by setting and allocating the state and history before sampling starts.
load_checkpoint
(path)Load the state of the sampler from a file.
Re-initialize the sampler.
sample
(Ns[, batch_size, sample_path])Sample Ns samples from the target density.
save_checkpoint
(path)Save the state of the sampler to a file.
set_history
(history)Set the history of the sampler.
set_state
(state)Set the state of the sampler.
step
()Perform one step of the sampler by transitioning the current point to a new point according to the sampler's transition kernel.
tune
(skip_len, update_count)Tune the parameters of the sampler.
Validate the target is compatible with the sampler.
warmup
(Nb[, tune_freq])Warmup the sampler by drawing Nb samples.
Attributes