proposal
samplermcmc.proposal
- class m3c2.proposal.AdaptiveKDE(names, **kwargs)[source]
Adaptive KDE proposal base on hypKDE library
- class m3c2.proposal.CovProposal(*args, **kwargs)[source]
Propose jumps out of the gaussian distibution defined by the covariance matrix and mode built from chain. Besides the standard arguments of the
Proposal
: class it accepts the following parameters:- Parameters:
adapt (int) – frequency (in steps) of the covariance update.
ini_mode (np.array) – initial mode of the proposal distribution. Default: null vector.
ini_cov (np.array) – initial covariance of the proposal dist. Default: diagonal 0.1 matrix.
get_qxy (bool) – return the ration of the proposal probabilities. Default: True.
- Returns:
propsed point, O, None, qxy
- Return type:
list
- class m3c2.proposal.DE(names, DE_skip=1000, **kwargs)[source]
A differential evolution sampler.
- DE(x, chain=None, **kwargs)[source]
Return actual sample using differential evolution of a given chain.
Args: x: the current position chain: all additional runtime data needed to propose a new point.
Returns: y: the new position status: 0 (do MH decision), 1 (accept) or -1 (reject) logy: the log-likelihood at y position if already computed. qxy: 0 for symmetric proposal distribution
- DE_all(x, chains=None, chain=None, **kwargs)[source]
Return actual sample using differential evolution of all chains.
Args: x: the current position chains, chain: all additional runtime data needed to propose a new point.
Returns: y: the new position status: 0 (do MH decision), 1 (accept) or -1 (reject) logy: the log-likelihood at y position if already computed. qxy: 0 for symmetric proposal distribution
- class m3c2.proposal.Gibbs(names, subset_names=[], cov=None, **kwargs)[source]
Proposal with jump in a subset of parameters only
- class m3c2.proposal.HyperModelWhat(names, nindex=0, bins=[0, 0.5, 1], model_names=[], update_step=1000, choose_model=<built-in method random of numpy.random.mtrand.RandomState object>, **kwargs)[source]
A proposal handling hyper models, where one parameter controls model selection.
- HMSCAM(x, chain=None, **kwargs)[source]
Return actual sample by jumping in one component direction.
Args: x: the current position chain: all additional runtime data needed to propose a new point.
Returns: y: the new position status: 0 (do MH decision), 1 (accept) or -1 (reject) logy: the log-likelihood at y position if already computed. qxy: 0 for symmetric proposal distribution
- HMslice(x, chain=None, **kwargs)[source]
Return actual sample by jumping in one component direction. Args: x: the current position chain: all additional runtime data needed to propose a new point.
Returns: y: the new position status: 0 (do MH decision), 1 (accept) or -1 (reject) logy: the log-likelihood at y position if already computed. qxy: 0 for symmetric proposal distribution
- class m3c2.proposal.ParSplitProposal(*args, **kwargs)[source]
Parameter splitting (and multi trial) proposal.
- Params int ntrials:
number of fast trials. Default 1000.
- Parameters:
slowp (function) –
proposition for slow pars. Signature slowp(old_slow, chain=None, chains=None)
returns: new_point, <ignored>, <ignored>, proposal_prob
it will be accessible via the proposal slow method call.
fastp (function) –
proposition for fast pars. Signature fastp(old_fast, chain=None, chains=None, **extra)
returns: new_point, <ignored>, <ignored>, <ignored>
where extra are the parameters returned by the slow_fun in ChainMultiTrial. it is wrapped by the proposal fast method to generate ntrial fast points.
fastlq (function) –
proposition probability for fast pars. Signature fastlq(old_fast, chain=None, chains=None, **extra)
returns the proposal probability (float)
where extra are the parameters returned by the slow_fun in ChainMultiTrial. it will be accessible via the proposal lq method call.
- class m3c2.proposal.Prior(names, prior, **kwargs)[source]
A simple sampler based on priors.
- sample_prior(x, chain=None, **kwargs)[source]
Return actual sample.
Args: x: the current position chain: all additional runtime data needed to propose a new point.
Returns: y: the new position status: 0 (do MH decision), 1 (accept) or -1 (reject) logy: the log-likelihood at y position if already computed. qxy: 0 for symmetric proposal distribution
- class m3c2.proposal.Proposal(names, logger=None, sort_name=None, sort_range=None, **kwargs)[source]
A proposal function. We use a class to stored meta-data and ease the customization.
- class m3c2.proposal.ReMHA(names, **kwargs)[source]
A Regional Metropolis Hastings Algorithm sampler.
- ReMHA(x, chain=None, **kwargs)[source]
Return actual sample by jumping in one component direction.
Args: x: the current position chain: all additional runtime data needed to propose a new point.
Returns: y: the new position status: 0 (do MH decision), 1 (accept) or -1 (reject) logy: the log-likelihood at y position if already computed. qxy: 0 for symmetric proposal distribution
- class m3c2.proposal.SCAM(names, get_cov=None, **kwargs)[source]
A Single Component Adaptive Metropolis sampler.
- SCAM(x, chain=None, **kwargs)[source]
Return actual sample by jumping in one component direction.
Args: x: the current position chain: all additional runtime data needed to propose a new point.
Returns: y: the new position status: 0 (do MH decision), 1 (accept) or -1 (reject) logy: the log-likelihood at y position if already computed. qxy: 0 for symmetric proposal distribution
- class m3c2.proposal.Slice(names, get_cov=None, get_dir=None, **kwargs)[source]
A slice sampler.
Any proposed points is accepted here.
- slice(x, chain=None, **kwargs)[source]
Return actual sample.
Args: x: the current position chain: all additional runtime data needed to propose a new point.
Returns: y: the new position status: 0 (do MH decision), 1 (accept) or -1 (reject) logy: the log-likelihood at y position if already computed. qxy: 0 for symmetric proposal distribution