binf.samplers package¶
Submodules¶
binf.samplers.gibbs module¶
Gibbs sampler implementations
-
class
binf.samplers.gibbs.GibbsSampler(pdf, state, subsamplers)[source]¶ Bases:
csb.statistics.samplers.mc.singlechain.AbstractSingleChainMC-
_abc_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version= 36¶
-
_abc_registry= <_weakrefset.WeakSet object>¶
-
_accept_proposal(proposal_state)¶ Accept the proposal state by setting it as the current state of the sampler object
@param proposal_state: The proposal state @type proposal_state: L{State}
-
_update_conditional_pdf_params()[source]¶ Updates parameters of the conditional PDFs to values set in this object’s PDF
-
_update_statistics(accepted)¶ Update the sampling statistics.
@param accepted: Whether or not the proposal state has been accepted @type accepted: boolean
-
acceptance_rate¶ Acceptance rate.
-
energy¶ Negative log-likelihood of the current state. @rtype: float
-
last_draw_stats¶ Returns information about most recent move for each subsampler
Returns: information about most recent move for each subsampler Return type: dict
-
last_move_accepted¶ Information whether the last MC move was accepted or not.
-
pdf¶ Returns the PDF object this sampler samples from
Returns: PDF object Return type: AbstractBinfPDF
-
sample()[source]¶ Performs one iteration of the Gibbs sampling scheme
Returns: a state Return type: BinfState
-
sampling_stats¶ Sampling statistics, consisting of sampler statistics of the subsamplers
Returns: all subsampler sampling statistics Return type: OrderedDict
-
subsamplers¶ Returns the subsamplers the Gibbs sampler iterates over
Returns: subsamplers for each variable Return type: dict
-
temperature¶
-
binf.samplers.hmc module¶
HMC sampler implementations
-
class
binf.samplers.hmc.HMCSampleStats(accepted, stepsize)¶ Bases:
tuple-
_asdict()¶ Return a new OrderedDict which maps field names to their values
-
_fields= ('accepted', 'stepsize')¶
-
classmethod
_make(iterable, new=<built-in method __new__ of type object>, len=<built-in function len>)¶ Make a new HMCSampleStats object from a sequence or iterable
-
_replace(**kwds)¶ Return a new HMCSampleStats object replacing specified fields with new values
-
accepted¶ Alias for field number 0
-
count(value) → integer -- return number of occurrences of value¶
-
index(value[, start[, stop]]) → integer -- return first index of value.¶ Raises ValueError if the value is not present.
-
stepsize¶ Alias for field number 1
-
-
class
binf.samplers.hmc.HMCSampler(pdf, state, timestep, nsteps, timestep_adaption_limit=0, adaption_uprate=1.05, adaption_downrate=0.95, variable_name=None)[source]¶ Bases:
object-
_adapt_timestep()[source]¶ Increases / decreasese the leap frog time step depending on whether the last move has been rejected / accepted.
-
_copy_state(state)[source]¶ Copies a state
Parameters: state (numpy.ndarray) – variable value to copy
-
_leapfrog(q, p, timestep, nsteps)[source]¶ Performs leap frog integration of Hamiltonian dynamics guided by the gradient of the negative log-probability
Parameters: Returns: ‘position’ and ‘momentum’ at the end of the approximated MD trajectory
Return type: (numpy.ndarray, numpy.ndarray)
-
acceptance_rate¶
-
last_draw_stats¶ Returns information about the most recently performed move
This is usually used by a replica exchange scheme to log sampling statistics.
Returns: whether the last move has been accepted and the current time step in the shape of a named tuple in a dictionary. This contrived is needed for Gibbs sampling / replica exchange statistics. Return type: dict
-
Module contents¶
This module contains implementations of various MCMC samplers