gcfit.core.MCMC_fit#
- gcfit.core.MCMC_fit(cluster, Niters, Nwalkers, Ncpu=2, *, mpi=False, initials=None, param_priors=None, moves=None, fixed_params=None, excluded_likelihoods=None, hyperparams=False, cont_run=False, savedir=PosixPath('.'), backup=False, restrict_to=None, compress=False, verbose=False, progress=False)#
Main MCMC fitting pipeline.
Execute the full MCMC cluster fitting algorithm.
Based on the given clusters Observations, determines the relevant likelihoods used to construct an MCMC ensemble sampler (emcee) and initializes it based on the initials stored in the Observations.
MCMC chains and information is stored using an HDF file backend, within the savedir directory under the filename “{cluster}_sampler.hdf”. Also stored within this file is various statistics and metadata surrounding the fitter run. Alongside each walker’s posterior probability profile is stored the individual likelihood values of each used likelihood function.
The MCMC sampler is sampled for Niters iterations, parallelized over Ncpu or using mpi, with calls to gcfit.posterior.
- Parameters:
- clusterstr
Cluster common name, as used to load gcfit.Observations.
- Nitersint
Number of sampler iterations.
- Nwalkersint
Number of sampler walkers.
- Ncpuint, optional
Number of CPU’s to parallelize the sampling computation over. Is ignored if mpi is True.
- mpibool, optional
Parallelize sampling computation using mpi rather than multiprocessing. Parallelization is handled by schwimmbad.
- initialsdict, optional
Dictionary of initial walker positions for each parameter. If None (default), uses the initials stored in the cluster’s Observations. Any missing parameters in initials will be filled with the values stored in the Observations.
- param_priorsdict, optional
Dictionary of prior bounds/args for each parameter. See probabilities.priors for formatting of args and defaults.
- moveslist of emcee.moves.Move, optional
List of MCMC proposal algorithms, or “moves”, as defined within emcee. This list is simply passed to emcee.EnsembleSampler.
- fixed_paramslist of str, optional
List of parameters to fix to the initial value, and not allow to be varied through the sampler.
- excluded_likelihoodslist of str, optional
List of component likelihoods to exclude from the posterior probability function. Each likelihood can be specified using either the name of the function (as given by __name__) or the name of the relevant dataset.
- hyperparamsbool, optional
Whether to include bayesian hyperparameters (see Hobson et al., 2002) in all likelihood functions.
- cont_runbool, optional
Not Implemented.
- savedirpath-like, optional
The directory within which the HDF output file is stored, defaults to the current working directory.
- backupbool, optional
If True, create a continuous backup HDF file every 100 iterations.
- restrict_to{None, ‘local’, ‘core’}
Where to search for the cluster data file, see gcfit.util.get_cluster_path for more information.
- compressbool, optional
If True, applies “gzip” compression to all datasets stored in the output file. Defaults to no compression.
- verbosebool, optional
Increase verbosity (currently only affects output of run final summary).
- progressbool, optional
Whether to displace emcee’s progress bar.
See also
emceeMCMC Ensemble sampler implementation.
schwimmbadInterface to parallel processing pools.