kliff.uq.mcmc¶
- kliff.uq.mcmc.logprior_uniform(x, bounds)[source]¶
Logarithm of the non-normalized joint uniform prior.
This is the default prior distribution.
- Parameters:
x (
ndarray) – (ndim,) Parameter values to evaluate.bounds (
ndarray) – (ndim, 2,) An array containing the boundaries of the uniform prior. The first column of the array contains the lower bounds and the second column contains the upper bounds.
- Return type:
float- Returns:
Logarithm of the non-normalized joint uniform prior evaluated at parameter
x.
- kliff.uq.mcmc.get_T0(loss)[source]¶
Compute the natural temperature.
The minimum loss is the loss value at the optimal parameters.
- class kliff.uq.mcmc.MCMC(loss: Loss, nwalkers: int | None = None, logprior_fn: Callable | None = None, logprior_args: tuple | None = None, sampler: str | None = 'ptemcee', **kwargs)[source]¶
MCMC sampler class for Bayesian uncertainty quantification.
This is a wrapper over
PtemceeSamplerandEmceeSampler. Currently, only these 2 samplers implemented.- Parameters:
loss – Loss function class from
Loss.nwalkers – Number of walkers to simulate. The minimum number of walkers is twice
value. (the number of parameters. It defaults to this minimum)
logprior_fn – A function that evaluate logarithm of the prior distribution. The prior doesn’t need to be normalized. It defaults to a uniform prior over a finite range.
logprior_args – Additional positional arguments of the
logprior_fn. If the defaultlogprior_fnis used, then the boundaries of the uniform prior can be specified here.sampler – An argument that specifies the MCMC sampler to use. The value can be one of the strings
"ptemcee"(the default value) or"emcee", or a sampler class instance. If"ptemcee"or"emcee"is given, a respective internal sampler class will be uses.**kwargs – Additional keyword arguments for
ptemcee.Sampleroremcee.EnsembleSampler.
- builtin_samplers = ['ptemcee', 'emcee']¶