**mcmc**¶

MCMC (Markov chain Monte Carlo) and related algorithms.

## Overview¶

- This module contains various classes that implement MCMC samplers:
`MCMC`

: the base class for all MCMC samplers;`GenericRWHM`

: base class for random-walk Hastings-Metropolis;`GenericGibbs`

: base class for Gibbs samplers;`PMMH`

,`ParticleGibbs`

: base classes for the PMCMC (particle MCMC algorithms) with the same name.

For instance, here is how to run 200 iterations of an adaptive random-walk sampler:

```
# ...
# define some_static_model, some_prior
# ...
my_mcmc = BasicRWHM(model=some_static_model, prior=some_prior, niter=200,
adaptive=True)
my_mcmc.run()
```

Upon completion, object `my_mcmc`

have an attribute called `chain`

, which
is a `ThetaParticles`

object (see module smc_samplers). In particular,
`my_mcmc.chain`

has the following attributes:

`theta`

: a structured array that contains the 200 simulated parameters;`lpost`

: an array that contains the log-posterior density at these 200 parameters.

See the dedicated notebook tutorial (on Bayesian inference for state-space models) for more examples and explanations.

## Module summary¶

`MCMC` |
MCMC base class. |

`GenericRWHM` |
Base class for random walk Hasting-Metropolis samplers. |

`GenericGibbs` |
Generic Gibbs sampler for a state-space model. |

`PMMH` |
Particle Marginal Metropolis Hastings. |

`ParticleGibbs` |
Particle Gibbs sampler (abstract class). |