rxmc.param_sampling.MetropolisHastingsSampler#
- class rxmc.param_sampling.MetropolisHastingsSampler(params: list[Parameter], prior, starting_location: ndarray, proposal: ProposalDistribution)[source]#
Bases:
SamplerMetropolis-Hastings sampler with a fixed proposal distribution.
- Parameters:
params (list of Parameter) – Parameters to sample.
prior (object) – Prior distribution with a callable
logpdf(x)method.starting_location (np.ndarray, shape (ndim,)) – Initial parameter vector.
proposal (ProposalDistribution) – Callable proposal distribution. Must accept
(x, rng)and return a proposed parameter vector.
- __init__(params: list[Parameter], prior, starting_location: ndarray, proposal: ProposalDistribution)[source]#
Methods
__init__(params, prior, starting_location, ...)batch_acceptance_fractions()Acceptance fraction for each completed batch.
most_recent_batch_acceptance_fraction()Acceptance fraction of the most recent batch.
overall_acceptance_fraction()Overall acceptance fraction across all completed batches.
record_batch(n_steps, n_accepted, chain, ...)Append a completed batch to the running chain.
sample(n_steps, starting_location, rng, ...)Run the sampling algorithm for one batch.