emcee.sampler module¶
The base sampler class implementing various helpful functions.
- class emcee.sampler.Sampler(dim, lnprobfn, args=[])[source]¶
Bases:
object
An abstract sampler object that implements various helper functions
- Parameters:
dim – The number of dimensions in the parameter space.
lnpostfn – A function that takes a vector in the parameter space as input and returns the natural logarithm of the posterior probability for that position.
args – (optional) A list of extra arguments for
lnpostfn
.lnpostfn
will be called with the sequencelnpostfn(p, *args)
.
- property acceptance_fraction¶
The fraction of proposed steps that were accepted.
- property acor¶
The autocorrelation time of each parameter in the chain (length:
dim
) as estimated by theacor
module.
- property chain¶
A pointer to the Markov chain.
- property flatchain¶
Alias of
chain
provided for compatibility.
- property lnprobability¶
A list of the log-probability values associated with each step in the chain.
- property random_state¶
The state of the internal random number generator. In practice, it’s the result of calling
get_state()
on anumpy.random.mtrand.RandomState
object. You can try to set this property but be warned that if you do this and it fails, it will do so silently.
- run_mcmc(pos0, N, rstate0=None, lnprob0=None, **kwargs)[source]¶
Iterate
sample()
forN
iterations and return the result.- Parameters:
p0 – The initial position vector.
N – The number of steps to run.
lnprob0 – (optional) The log posterior probability at position
p0
. Iflnprob
is not provided, the initial value is calculated.rstate0 – (optional) The state of the random number generator. See the
random_state()
property for details.kwargs – (optional) Other parameters that are directly passed to
sample()
.