A parallel-tempered ensemble sampler, using :class:`EnsembleSampler`
for sampling within each parallel chain.
:param ntemps:
The number of temperatures.
:param nwalkers:
The number of ensemble walkers at each temperature.
:param dim:
The dimension of parameter space.
:param logl:
The log-likelihood function.
:param logp:
The log-prior function.
:param threads: (optional)
The number of parallel threads to use in sampling.
:param pool: (optional)
Alternative to ``threads``. Any object that implements a
``map`` method compatible with the built-in ``map`` will do
here. For example, :class:`multi.Pool` will do.
:param betas: (optional)
Array giving the inverse temperatures, :math:`\\beta=1/T`, used in the
ladder. The default is for an exponential ladder, with beta
decreasing by a factor of :math:`1/\\sqrt{2}` each rung.
Definition at line 69 of file ptsampler.py.
def emcee.ptsampler.PTSampler.sample |
( |
|
self, |
|
|
|
p0, |
|
|
|
lnprob0 = None , |
|
|
|
lnlike0 = None , |
|
|
|
iterations = 1 , |
|
|
|
thin = 1 , |
|
|
|
storechain = True |
|
) |
| |
Advance the chains ``iterations`` steps as a generator.
:param p0:
The initial positions of the walkers. Shape should be
``(ntemps, nwalkers, dim)``.
:param lnprob0: (optional)
The initial posterior values for the ensembles. Shape
``(ntemps, nwalkers)``.
:param lnlike0: (optional)
The initial likelihood values for the ensembles. Shape
``(ntemps, nwalkers)``.
:param iterations: (optional)
The number of iterations to preform.
:param thin: (optional)
The number of iterations to perform between saving the
state to the internal chain.
:param storechain: (optional)
If ``True`` store the iterations in the ``chain``
property.
At each iteration, this generator yields
* ``p``, the current position of the walkers.
* ``lnprob`` the current posterior values for the walkers.
* ``lnlike`` the current likelihood values for the walkers.
Definition at line 159 of file ptsampler.py.
def emcee.ptsampler.PTSampler.thermodynamic_integration_log_evidence |
( |
|
self, |
|
|
|
logls = None , |
|
|
|
fburnin = 0.1 |
|
) |
| |
Thermodynamic integration estimate of the evidence.
:param logls: (optional) The log-likelihoods to use for
computing the thermodynamic evidence. If ``None`` (the
default), use the stored log-likelihoods in the sampler.
Should be of shape ``(Ntemps, Nwalkers, Nsamples)``.
:param fburnin: (optional)
The fraction of the chain to discard as burnin samples; only the
final ``1-fburnin`` fraction of the samples will be used to
compute the evidence; the default is ``fburnin = 0.1``.
:return ``(lnZ, dlnZ)``: Returns an estimate of the
log-evidence and the error associated with the finite
number of temperatures at which the posterior has been
sampled.
The evidence is the integral of the un-normalized posterior
over all of parameter space:
.. math::
Z \\equiv \\int d\\theta \\, l(\\theta) p(\\theta)
Thermodymanic integration is a technique for estimating the
evidence integral using information from the chains at various
temperatures. Let
.. math::
Z(\\beta) = \\int d\\theta \\, l^\\beta(\\theta) p(\\theta)
Then
.. math::
\\frac{d \\ln Z}{d \\beta}
= \\frac{1}{Z(\\beta)} \\int d\\theta l^\\beta p \\ln l
= \\left \\langle \\ln l \\right \\rangle_\\beta
so
.. math::
\\ln Z(\\beta = 1)
= \\int_0^1 d\\beta \\left \\langle \\ln l \\right\\rangle_\\beta
By computing the average of the log-likelihood at the
difference temperatures, the sampler can approximate the above
integral.
Definition at line 307 of file ptsampler.py.