API of sampleEMCEE¶
- PyAstronomy.funcFit.sampleEMCEE(fpns, fv0, lnp, largs=None, nwalker=None, scales=None, sampleArgs=None, dbfile='chain.emcee', ps=None, emcp=None)¶
MCMC sampling from specific density using the emcee package.
This function may be used to use emcee to sample from any user-specified density, which does not have to be normalized. The resulting Markov Chains can be analyzed using the trace analysis package.
- Parameters
- fpnslist of strings
Names of parameters for which Markov Chains are constructed.
- fv0dictionary
A dictionary mapping parameter name to starting value. This dictionary may contain any number of additional key-value pairs
- lnpcallable
A function (or equivalent callable) which returns the (natural) logarithm of the (generally unnormalized) density. The first (and only mandatory) argument to the function is a dictionary holding the current parameter values for which the posterior density is to be evaluated. The function may take any number of additional keyword arguments, which can be specifies by the largs parameter.
- largsdictionary, optional
A set of additional arguments passed to the lnp callable.
- nwalkerint, optional
The number of walker to be used. By default, four times the number of free parameters is used.
- scalesdictionary, optional
The scales argument can be used to control the initial distribution of the walkers. By default, all walkers are distributed around the location given by the current state of the object, i.e., the current parameter values. In each direction, the walkers are randomly distributed with a Gaussian distribution, whose default standard deviation is one. The scales argument can be used to control the width of the Gaussians used to distribute the walkers.
- sampleArgsdictionary, optional
Number controlling the sampling process. Use ‘burn’ (int) to specify the number of burn-in iterations (default is 0). Via ‘iters’ (int) the numbers of iterations after the burn-in can be specified (default 1000). The ‘process’ (int) key can be used to control the number of iterations after which the progress bar is updated (default is iters/100). Note that the ‘progressbar’ package must be installed to get a progress bar. Otherwise more mundane print statements will be used.
- dbfilestring, optional
The result of the sampling, i.e., the chain(s), the corresponding values of the posterior, and the names of the free parameters are saved to the specified file (by default ‘chain.emcee’ is used). The traces stored there can be analyzed using the ‘TraceAnalysis’ class. Set this parameter to ‘None’ to avoid saving the results.
- pstuple, optional
A tuple holding the current position and state of the sampler. This tuple is returned by this method. The ps argument can be used to continue sampling from the last state. Note that no burn-in will ne carried out and the other arguments should be given as previously to continue sampling successfully.
- emcpdictionary, optional
Extra arguments handed to EnsembleSampler object.
- Returns
- pos, statestate of emcee sample
These information may be used to continue the sampling from previous position.