MHSampler
- class ssapy.rvsampler.MHSampler(probfn, initializer, proposer, nChain)[source][source]
Bases:
object
Generate MCMC samples using a Metropolis-Hastings sampler.
- Parameters:
probfn (Callable) – Callable that accepts sampling parameters p and returns posterior probability.
initializer (Callable) – Callable that accepts number of desired initial samples and returns samples. Note, the initial samples should be (at least mostly) unique.
proposer (Callable) – Callable that accepts a “current” sample and returns a “proposed” sample to either accept or reject at each step.
nChain (int) – Number of independent chains to use.
- sample(nBurn, nStep)[source][source]
Generate samples, first discarding nBurn steps, and then keeping nStep steps.
Attributes Summary
Ratio of accepted to proposed steps.
Methods Summary
reset
()Reset chain, including chain, lnprob, nAccept, and nStep attributes.
sample
([nBurn, nStep])Generate samples.
Attributes Documentation
Methods Documentation
- sample(nBurn=1000, nStep=500)[source][source]
Generate samples.
- Parameters:
- Returns:
chain (array (nStep, nChain, 6)) – Generated samples. Columns are [x, y, z, vx, vy, vz].
lnprob (array (nStep, nChain)) – The log posterior probabilities of the samples.
lnprior (array (nStep, nChain)) – The log prior probabilities of the samples.