pastas.solver.mcmc.Emcee#
- class pastas.solver.mcmc.Emcee(model: pastas.typing.Model, name: str = 'solver', objfunction: pastas.solver.objective.likelihood.LikelihoodBase | None = None, nwalkers: int = 20, nsteps: int = 5000, backend: Any | None = None, moves: Any | collections.abc.Iterable[Any] | None = None, parallel: bool | None = None, progress_bar: bool = True, **kwargs: Any)#
Solver based on MCMC approach in emcee [Foreman-Mackey et al., 2013].
- Parameters:
objfunction (pastas.solver.objective.likelihood.LikelihoodBase, optional) – The objective function to be minimized.
nwalkers (int, optional) – Number of walkers to use. Default is 20.
backend (emcee.backend, optional) – One of the Backends from Emcee used to store MCMC results. See the Emcee documentation for more information.
moves (emcee.moves, optional) – The moves argument determines how the next step for a walker is chosen in the MCMC approach. One of the Moves classes from Emcee has to be provided. See Emcee documentation for more information.
parallel (bool, optional) – Run the sampler in parallel or not. By default, the parallel option is set to the value of the global Pastas option.
progress_bar (bool, optional) – Show the progress bar or not. Requires the tqdm package to be installed.
**kwargs – All other keyword arguments are passed on to the SolverBase class.
optional – All other keyword arguments are passed on to the SolverBase class.
See also
emcee.EnsembleSampler,emcee.moves,emcee.backend,pastas.solver.objective.likelihoodNotes
The EmceeSolve solver uses the emcee package to perform a Markov Chain Monte Carlo (MCMC) approach to find the optimal parameter values. The solver can be used as follows:
solver = ps.solver.Emcee(ml, nwalkers=20, nsteps=5000, progress_bar=True)
The attributes provided are mostly passed on to the emcee.EnsembleSampler and determine how that instance is created. Keyword arguments to model.solve are parsed to emcee.EnsembleSampler.sample via the run_mcmc method like:
ml.solve(thin_by=2)
To obtain the MCMC chains, use:
ml.solver.sampler.get_chain(flat=True, discard=3000)
References
Methods#
|
Get initial parameters for the solver. |
|
Solve the model using MCMC. |
|
Full log-probability called by Emcee. |
|
Log-likelihood function. |
|
Probability of parameter set given the priors. |
|
Report on the fit after a model is optimized. |
|
Not supported for this solver. |