UGLA#
- class cuqi.experimental.mcmc.UGLA(target=None, initial_point=None, maxit=50, tol=0.0001, beta=1e-05, **kwargs)#
Unadjusted (Gaussian) Laplace Approximation sampler
Samples an approximate posterior where the prior is approximated by a Gaussian distribution. The likelihood must be Gaussian.
Currently only works for LMRF priors.
The inner solver is Conjugate Gradient Least Squares (CGLS) solver.
For more details see: Uribe, Felipe, et al. A hybrid Gibbs sampler for edge-preserving tomographic reconstruction with uncertain view angles. SIAM/ASA Journal on UQ, https://doi.org/10.1137/21M1412268 (2022).
- Parameters:
target (cuqi.distribution.Posterior) – The target posterior distribution to sample.
initial_point (ndarray, Optional) – Initial parameters. If not provided, it defaults to zeros.
maxit (int) – Maximum number of inner iterations for solver when generating one sample. If not provided, it defaults to 50.
tol (float) – Tolerance for inner solver. The inner solvers will stop before maxit if convergence check reaches tol. If not provided, it defaults to 1e-4.
beta (float) – Smoothing parameter for the Gaussian approximation of the Laplace distribution. A small value in the range of 1e-7 to 1e-3 is recommended, though values out of this range might give better results in some cases. Generally, a larger beta value makes sampling easier but results in a worse approximation. See details in Section 3.3 of the paper. If not provided, it defaults to 1e-5.
callback (callable, Optional) – If set, this function will be called after every sample. The signature of the callback function is callback(sample, sample_index), where sample is the current sample and sample_index is the index of the sample. An example is shown in demos/demo31_callback.py.
- __init__(target=None, initial_point=None, maxit=50, tol=0.0001, beta=1e-05, **kwargs)#
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, maxit, ...])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