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) – A function that will be called after each sampling step. It can be useful for monitoring the sampler during sampling. The function should take three arguments: the sampler object, the index of the current sampling step, the total number of requested samples. The last two arguments are integers. An example of the callback function signature is: callback(sampler, sample_index, num_of_samples).
- __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 sampling step. It can be useful for monitoring the sampler during sampling. The function should take three arguments: the sampler object, the index of the current sampling step, the total number of requested samples. The last two arguments are integers. An example of the callback function signature is: callback(sampler, sample_index, num_of_samples).
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