The default behavior for adding and solving with noisemodels has changed from Pastas 1.5. Find more information here

EmceeSolve#

class EmceeSolve(objective_function=None, nwalkers=20, backend=None, moves=None, parallel=False, progress_bar=True, **kwargs)[source]#

Solver based on MCMC approach in emcee [Foreman-Mackey et al., 2013].

Parameters
  • objective_function (func, optional) – An objective function to be minimized. If not provided, the GaussianLikelihood is used. See the pastas.objective_functions module for more information.

  • 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 Emcee 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.

  • 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 BaseSolver class.

  • optional – All other keyword arguments are passed on to the BaseSolver class.

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)

Examples

>>> ml.solve(solver=ps.EmceeSolve(), steps=5000)

To obtain the MCMC chains, use:

>>> ml.solver.sampler.get_chain(flat=True, discard=3000)

References

https://emcee.readthedocs.io/en/stable/

See also

emcee.EnsembleSampler, emcee.moves, emcee.backend, pastas.objective_functions

Methods#

__init__

ci_block_response

Method to calculate the confidence interval for the block response.

ci_contribution

Method to calculate the confidence interval for the contribution.

ci_simulation

Method to calculate the confidence interval for the simulation.

ci_step_response

Method to calculate the confidence interval for the step response.

get_parameter_sample

Method to obtain a parameter sets for monte carlo analyses.

log_likelihood

Log-likelihood function.

log_prior

Probability of parameter set given the priors.

log_probability

Full log-probability called by Emcee.

misfit

This method is called by all solvers to obtain a series that are minimized in the optimization process.

prediction_interval

Method to calculate the prediction interval for the simulation.

set_model

Method to set the Pastas Model instance.

set_parameter

Method to change the parameter properties.

solve

to_dict

This method is not supported for this solver.