gstlal-inspiral  0.4.2
 All Classes Namespaces Files Functions Variables Pages
List of all members | Public Member Functions | Public Attributes
emcee.ensemble.EnsembleSampler Class Reference
Inheritance diagram for emcee.ensemble.EnsembleSampler:
[legend]
Collaboration diagram for emcee.ensemble.EnsembleSampler:
[legend]

Public Member Functions

def __init__
def reset
def sample
def blobs
def chain
def flatchain
def lnprobability
def flatlnprobability
def acceptance_fraction
def acor

Public Attributes

 k
 a
 threads
 pool
 lnprobfn
 naccepted
 random_state

Detailed Description

A generalized Ensemble sampler that uses 2 ensembles for parallelization.
The ``__init__`` function will raise an ``AssertionError`` if
``k < 2 * dim`` (and you haven't set the ``live_dangerously`` parameter)
or if ``k`` is odd.

**Warning**: The :attr:`chain` member of this object has the shape:
``(nwalkers, nlinks, dim)`` where ``nlinks`` is the number of steps
taken by the chain and ``k`` is the number of walkers.  Use the
:attr:`flatchain` property to get the chain flattened to
``(nlinks, dim)``. For users of pre-1.0 versions, this shape is
different so be careful!

:param nwalkers:
    The number of Goodman & Weare "walkers".

:param dim:
    Number of dimensions in the parameter space.

:param 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.

:param a: (optional)
    The proposal scale parameter. (default: ``2.0``)

:param args: (optional)
    A list of extra arguments for ``lnpostfn``. ``lnpostfn`` will be
    called with the sequence ``lnpostfn(p, *args)``.

:param postargs: (optional)
    Alias of ``args`` for backwards compatibility.

:param threads: (optional)
    The number of threads to use for parallelization. If ``threads == 1``,
    then the ``multiprocessing`` module is not used but if
    ``threads > 1``, then a ``Pool`` object is created and calls to
    ``lnpostfn`` are run in parallel.

:param pool: (optional)
    An alternative method of using the parallelized algorithm. If
    provided, the value of ``threads`` is ignored and the
    object provided by ``pool`` is used for all parallelization. It
    can be any object with a ``map`` method that follows the same
    calling sequence as the built-in ``map`` function.

Definition at line 28 of file ensemble.py.

Member Function Documentation

def emcee.ensemble.EnsembleSampler.acceptance_fraction (   self)
An array (length: ``k``) of the fraction of steps accepted for each
walker.

Definition at line 428 of file ensemble.py.

def emcee.ensemble.EnsembleSampler.acor (   self)
The autocorrelation time of each parameter in the chain (length:
``dim``) as estimated by the ``acor`` module.

Definition at line 437 of file ensemble.py.

def emcee.ensemble.EnsembleSampler.blobs (   self)
Get the list of "blobs" produced by sampling. The result is a list
(of length ``iterations``) of ``list`` s (of length ``nwalkers``) of
arbitrary objects. **Note**: this will actually be an empty list if
your ``lnpostfn`` doesn't return any metadata.

Definition at line 380 of file ensemble.py.

def emcee.ensemble.EnsembleSampler.chain (   self)
A pointer to the Markov chain itself. The shape of this array is
``(k, iterations, dim)``.

Definition at line 391 of file ensemble.py.

def emcee.ensemble.EnsembleSampler.flatchain (   self)
A shortcut for accessing chain flattened along the zeroth (walker)
axis.

Definition at line 400 of file ensemble.py.

def emcee.ensemble.EnsembleSampler.flatlnprobability (   self)
A shortcut to return the equivalent of ``lnprobability`` but aligned
to ``flatchain`` rather than ``chain``.

Definition at line 419 of file ensemble.py.

def emcee.ensemble.EnsembleSampler.lnprobability (   self)
A pointer to the matrix of the value of ``lnprobfn`` produced at each
step for each walker. The shape is ``(k, iterations)``.

Definition at line 410 of file ensemble.py.

def emcee.ensemble.EnsembleSampler.reset (   self)
Clear the ``chain`` and ``lnprobability`` array. Also reset the
bookkeeping parameters.

Definition at line 102 of file ensemble.py.

def emcee.ensemble.EnsembleSampler.sample (   self,
  p0,
  lnprob0 = None,
  rstate0 = None,
  blobs0 = None,
  iterations = 1,
  thin = 1,
  storechain = True,
  mh_proposal = None 
)
Advance the chain ``iterations`` steps as a generator.

:param p0:
    A list of the initial positions of the walkers in the
    parameter space. It should have the shape ``(nwalkers, dim)``.

:param lnprob0: (optional)
    The list of log posterior probabilities for the walkers at
    positions given by ``p0``. If ``lnprob is None``, the initial
    values are calculated. It should have the shape ``(k, dim)``.

:param rstate0: (optional)
    The state of the random number generator.
    See the :attr:`Sampler.random_state` property for details.

:param iterations: (optional)
    The number of steps to run.

:param thin: (optional)
    If you only want to store and yield every ``thin`` samples in the
    chain, set thin to an integer greater than 1.

:param storechain: (optional)
    By default, the sampler stores (in memory) the positions and
    log-probabilities of the samples in the chain. If you are
    using another method to store the samples to a file or if you
    don't need to analyse the samples after the fact (for burn-in
    for example) set ``storechain`` to ``False``.

:param mh_proposal: (optional)
    A function that returns a list of positions for ``nwalkers``
    walkers given a current list of positions of the same size. See
    :class:`utils.MH_proposal_axisaligned` for an example.

At each iteration, this generator yields:

* ``pos`` — A list of the current positions of the walkers in the
  parameter space. The shape of this object will be
  ``(nwalkers, dim)``.

* ``lnprob`` — The list of log posterior probabilities for the
  walkers at positions given by ``pos`` . The shape of this object
  is ``(nwalkers, dim)``.

* ``rstate`` — The current state of the random number generator.

* ``blobs`` — (optional) The metadata "blobs" associated with the
  current position. The value is only returned if ``lnpostfn``
  returns blobs too.

Definition at line 117 of file ensemble.py.


The documentation for this class was generated from the following file: