pastas.solver.EmceeSolve ======================== .. toctree:: :hidden: /api/pastas/solver/EmceeSolve.log_probability /api/pastas/solver/EmceeSolve.log_likelihood /api/pastas/solver/EmceeSolve.log_prior /api/pastas/solver/EmceeSolve.set_parameter /api/pastas/solver/EmceeSolve.to_dict .. py:class:: pastas.solver.EmceeSolve(objective_function=None, nwalkers: int = 20, backend=None, moves=None, parallel: bool = False, progress_bar: bool = True, **kwargs) Solver based on MCMC approach in emcee :cite:p:`foreman-mackey_emcee_2013`. :param objective_function: An objective function to be minimized. If not provided, the GaussianLikelihood is used. See the pastas.objective_functions module for more information. :type objective_function: func, 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 Emcee 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 BaseSolver class. :param optional: All other keyword arguments are passed on to the BaseSolver 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.EmceeSolve( 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.EmceeSolve(), thin_by=2) .. rubric:: Examples Example usage:: ml.solve(solver=ps.EmceeSolve(), 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.objective_functions` .. !! processed by numpydoc !! Methods ------- .. autoapisummary:: pastas.solver.EmceeSolve.log_probability pastas.solver.EmceeSolve.log_likelihood pastas.solver.EmceeSolve.log_prior pastas.solver.EmceeSolve.set_parameter pastas.solver.EmceeSolve.to_dict