chain
samplermcmc.chain
- class m3c2.chain.Chain(dim, beta, dbeta, log_l, log_p, **kwargs)[source]
A tempered chain and its associated proposals.
- add(i, p, lik, prior, is_max=False)[source]
Add a new point and update Mx, logL, logP, Lx, Px
if is_max is True, also update maxL and maxP.
- class m3c2.chain.ChainParsSplitting(*args, **kwargs)[source]
Chain extension handling multitrial with fast and slow parameters. These are the parameters added and the main differencies
Parameter splitting and multitrial: :param int ntrials: max number of fast parameters trials. :param int nslow: the first nslow parameters are considered as
“slow”. This is ignored if the slow_mask/fast_mask arguments are given.
- Parameters:
slow_mask (callable) – mask of the slow parameters. By default the first nslow parameters.
fast_mask (callable) – mask of the fast parameters. By default the last dim - nslow pars.
Likelihoods: :param callable slow_fun: function accepting the slow parameters as
argument and returning a dictionnary of “extra” parameters that will be passed to proposal and to the likelihood functions. This is meant to encode the “slow” part of the computation.
- Parameters:
fast_log_l (callable) – fast log likelihood. Accepts, as argument, the fast parameters and the “extra” named parameters. return the fast part of the log likelihood.
slow_log_l (callable) – (fast computation of the) slow log likelihood. Accepts, as argument, the wslow parameters and the “extra” named parameters. return the slow part of the log likelihood.
log_l (callable) – full log likelihood. This is the loglik argument of the Sampler initialization. If None it will be computed as the product of the fast_log_l and slow_log_l functions. It should accept as argument the point and the “extra” parameters. (Note: It will be wrapped so to be possible to call it without the extra parametes.
- Note: if fast_log_l and slow_log_l arguments are not given, the Chain implements
a standard acceptance with the full likelihood and uses the splitting between fast and slow parameters only for the proposals.
Priors: :param callable fast_log_p: prior function for the fast parameters. :param callable log_p: prior function for the slow param. This is the ‘logpi’
argument of the Sampler initialization.
Covariance: :param bool full_cov: if True computes the full parameters covariance.
Default False.
- Parameters:
slow_cov (bool) – if True computes the slow parameters covariance. Default True.
fast_cov (bool) – if true computes the fast parameters covariance. Default False.
Proposals: The main difference with the non-MT chain is that when defining the proposals dictionnary, one should specify the proposal object rather than the method. The proposal is supposed to have fast, slow and lq methods that will be called by the chain. See prposal.MTProposal.
- add(i, p, lik, prior, **kwargs)[source]
Add a new point and update Mx, logL, logP, Lx, Px
if is_max is True, also update maxL and maxP.