pastas.solver.mcmc.Emcee ======================== .. toctree:: :hidden: /api/pastas/solver/mcmc/Emcee.get_init_parameters /api/pastas/solver/mcmc/Emcee.solve /api/pastas/solver/mcmc/Emcee.log_probability /api/pastas/solver/mcmc/Emcee.log_likelihood /api/pastas/solver/mcmc/Emcee.log_prior /api/pastas/solver/mcmc/Emcee.fit_report /api/pastas/solver/mcmc/Emcee.to_dict .. py:class:: pastas.solver.mcmc.Emcee(name: str = 'solver', objfunction: pastas.solver.likelihood.GaussianLikelihood | pastas.solver.likelihood.GaussianLikelihoodAr1 | None = GaussianLikelihood(), nwalkers: int = 20, backend: Any | None = None, moves: Any | None = None, parallel: bool = False, progress_bar: bool = True, **kwargs: Any) Solver based on MCMC approach in emcee :cite:p:`foreman-mackey_emcee_2013`. :param objfunction: An objective function to be minimized. See the pastas.likelihood module for more information. :type objfunction: pastas.solver.likelihood function, optional :param nwalkers: Number of walkers to use. Default is 20. :type nwalkers: int, optional :param backend: One of the Backends from Emcee used to store MCMC results. See the Emcee documentation for more information. :type backend: emcee.backend, optional :param moves: 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. :type moves: emcee.moves, optional :param parallel: Run the sampler in parallel or not. :type parallel: bool, optional :param progress_bar: Show the progress bar or not. Requires the `tqdm` package to be installed. :type progress_bar: bool, optional :param \*\*kwargs: All other keyword arguments are passed on to the SolverBase class. :param optional: All other keyword arguments are passed on to the SolverBase class. .. rubric:: Notes 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(nwalkers=20, progress_bar=True) ml.solve(solver=solver) The arguments provided are mostly passed on to the `emcee.EnsembleSampler` and determine how that instance is created. Arguments you want to pass on to `run_mcmc` (and indirectly the `sample` method), can be passed on to `Model.solve`, like:: ml.solve(solver=ps.solver.Emcee(), thin_by=2) .. rubric:: Examples Example usage:: ml.solve(solver=ps.solver.Emcee(), steps=5000) To obtain the MCMC chains, use:: ml.solver.sampler.get_chain(flat=True, discard=3000) .. rubric:: References https://emcee.readthedocs.io/en/stable/ .. seealso:: :py:obj:`emcee.EnsembleSampler`, :py:obj:`emcee.moves`, :py:obj:`emcee.backend`, :py:obj:`pastas.solver.objective_function` .. !! processed by numpydoc !! Methods ------- .. autoapisummary:: pastas.solver.mcmc.Emcee.get_init_parameters pastas.solver.mcmc.Emcee.solve pastas.solver.mcmc.Emcee.log_probability pastas.solver.mcmc.Emcee.log_likelihood pastas.solver.mcmc.Emcee.log_prior pastas.solver.mcmc.Emcee.fit_report pastas.solver.mcmc.Emcee.to_dict