State

The eryn.state.State carries the information around for all walkers at a given step. The individual branches are carried in eryn.state.Branch class objects. A utility provided for state objects is the eryn.state.BranchSupplimental object. This object can carry information around the sampler while being indexed and moved around just like other sampler information. See the tutorial for more information.

class eryn.state.State(coords, inds=None, branch_supplemental=None, supplemental=None, log_like=None, log_prior=None, betas=None, blobs=None, random_state=None, copy=False)

Bases: object

The state of the ensemble during an MCMC run

Parameters:
  • coords (double ndarray[ntemps, nwalkers, nleaves_max, ndim], dict, or State) – The current positions of the walkers in the parameter space. If dict, need to use branch_names for the keys.

  • inds (bool ndarray[ntemps, nwalkers, nleaves_max] or dict, optional) – The information on which leaves are used and which are not used. A value of True means the specific leaf was used in this step. If dict, need to use branch_names for the keys. Input should be None if a complete State object is input for coords. (default: None)

  • log_like (ndarray[ntemps, nwalkers], optional) – Log likelihoods for the walkers at positions given by coords. Input should be None if a complete State object is input for coords. (default: None)

  • log_prior (ndarray[ntemps, nwalkers], optional) – Log priors for the walkers at positions given by coords. Input should be None if a complete State object is input for coords. (default: None)

  • betas (ndarray[ntemps], optional) – Temperatures in the sampler at the current step. Input should be None if a complete State object is input for coords. (default: None)

  • blobs (ndarray[ntemps, nwalkers, nblobs], Optional) – The metadata “blobs” associated with the current position. The value is only returned if lnpostfn returns blobs too. Input should be None if a complete State object is input for coords. (default: None)

  • random_state (Optional) – The current state of the random number generator. Input should be None if a complete State object is input for coords. (default: None)

  • copy (bool, optional) – If True, copy the the arrays in the former State obhect.

Raises:

ValueError – Dimensions of inputs or input types are incorrect.

property branches_inds

Get the inds from all branch objects returned as a dictionary with branch_names as keys.

property branches_coords

Get the coords from all branch objects returned as a dictionary with branch_names as keys.

property branches_supplemental

Get the branch.supplemental from all branch objects returned as a dictionary with branch_names as keys.

property branch_names

Get the branch names in this state.

get_log_posterior(temper: bool = False)

Get the posterior probability

Parameters:

temper (bool, optional) – If True, apply tempering to the posterior computation.

Returns:

Log of the posterior probability.

Return type:

np.ndarray[ntemps, nwalkers]

class eryn.state.Branch(coords, inds=None, branch_supplemental=None)

Bases: object

Special container for one branch (model)

This class is a key component of Eryn. It this type of object that allows for different models to be considered simultaneously within an MCMC run.

Parameters:
  • coords (4D double np.ndarray[ntemps, nwalkers, nleaves_max, ndim]) – The coordinates in parameter space of all walkers.

  • inds (3D bool np.ndarray[ntemps, nwalkers, nleaves_max], optional) – The information on which leaves are used and which are not used. A value of True means the specific leaf was used in this step. Parameters from unused walkers are still kept. When they are output to the backend, the backend saves a special number (default: np.nan) for all coords related to unused leaves at that step. If None, inds will fill with all True values. (default: None)

  • branch_supplemental (object) – BranchSupplemental object specific to this branch. (default: None)

Raises:

ValueErrorinds has wrong shape or number of leaves is less than zero.

property nleaves

Number of leaves for each walker