Skip to content

Probabilistic inference, Monte Carlo, and posterior computation · Probabilistic computation and inference foundations · INF016 · Algorithm

Particle Markov chain Monte Carlo (PMCMC)

Uses particle methods inside a correctly constructed MCMC transition to infer static parameters and latent trajectories in state-space models. Particle marginal MH and particle Gibbs are related members;

Partly runs in CodeSplash Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method covers part of this entry; some options or variants aren't built yet.

Do it in CodeSplash Run it on your own data, in Python or R.

Availability
Partly runs in CodeSplash
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
Verified in Python and R through ts.particle_filter. The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Uses particle methods inside a correctly constructed MCMC transition to infer static parameters and latent trajectories in state-space models. Particle marginal MH and particle Gibbs are related members; this entry illustrates the former rather than counting each as a separate model.

Question / hypotheses

Can a random particle-filter likelihood estimate be used inside an MCMC acceptance ratio without changing the desired parameter posterior?

Architecture / computational structure

Propose new parameters, run a particle filter to produce a new likelihood estimate and associated state, then apply the extended-target MH decision. On rejection retain both the old parameters and old estimate. Particle Gibbs instead relies on conditional SMC and a retained trajectory; it is not the same acceptance formula.

Assumptions

Particle marginal MH requires a nonnegative unbiased estimate of the likelihood, a properly constructed extended-state chain, and valid proposal/support conditions. Unbiasedness of the log likelihood is not the requirement. The current likelihood estimate and its random state are retained after rejection.

Formula / computational definition

α=min⁡(1,Z^(θ′,u′)p(θ′)q(θ∣θ′)Z^(θ,u)p(θ)q(θ′∣θ)),Eu[Z^(θ,u)]=p(y∣θ).\alpha=\min\left(1,\frac{\widehat Z(\theta^\prime,u^\prime)p(\theta^\prime)q(\theta\mid\theta^\prime)}{\widehat Z(\theta,u)p(\theta)q(\theta^\prime\mid\theta)}\right),\quad E_u[\widehat Z(\theta,u)]=p(y\mid\theta).

Parameters and notation

Theta contains static model parameters, u represents particle-filter randomness, and latent paths may be retained. Hyperparameters include particle count, parameter-proposal covariance, chain/warmup lengths, and filter settings. Noise in the likelihood estimator controls mixing and must be balanced against particle cost.

Fitting, fine-tuning, and adaptation

Tune parameter proposals and particle budgets during a pilot/warmup protocol, then use a valid sampling scheme. A changed observation model or dataset defines a new posterior. If the model contains neural transition weights, their dimension and expensive filter likelihood may make a full parameter chain impractical.

How to use and calibrate

Measure repeated likelihood estimates at representative parameters and inspect chain stickiness, effective samples per second, and multiple-chain diagnostics. Compare to exact Kalman likelihoods on a linear-Gaussian special case to validate the particle likelihood and MH construction.

Example application

Infer unknown process-noise or nonlinear dynamical parameters jointly with latent sensor states when likelihood evaluation requires integrating over an entire hidden trajectory.

Interpretation / pitfalls

Watch out

Recomputing the current likelihood independently on every comparison produces a different noisy-MH scheme that is generally not exact PMMH. A severely noisy estimator can make the chain sticky even though the invariant-target construction is correct. Finite particles do not imply finite-run convergence.

Python and R code examples

Scope: A particle marginal MH acceptance decision using supplied likelihood estimates and a symmetric proposal; no filter, latent-path update, or complete PMCMC chain.

Implementation route: Python/base R perform the scalar decision natively. R pomp implements pmcmc for specified state-space models. A Python implementation must couple a valid particle likelihood estimator to the extended-state transition; simply inserting arbitrary stochastic losses is not sufficient.

Dependencies and validation: Python — executed successfully on the supplied synthetic inputs; imports identify NumPy/SciPy dependencies. R — base R, reviewed but not executed because Rscript is unavailable. Random-number streams differ between languages; matching seed integers do not imply matching draws.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — A particle marginal MH acceptance decision using supplied likelihood estimates and a symmetric proposal; no filter, latent-path update, or complete PMCMC chain.

import math
theta=.5; logZ=-10.; proposed=.7; proposed_logZ=-10.4
logratio=proposed_logZ-logZ-.5*proposed**2+.5*theta**2  # N(0,1) prior; symmetric proposal
accepted=math.log(.7)<min(0.,logratio)
if accepted: theta,logZ=proposed,proposed_logZ
assert not accepted and logZ==-10.
print('acceptance probability',math.exp(min(0.,logratio)),'retained state',theta,logZ)
R

Component demo, not a trained model — A particle marginal MH acceptance decision using supplied likelihood estimates and a symmetric proposal; no filter, latent-path update, or complete PMCMC chain.

theta <- .5; logZ <- -10; proposed <- .7; proposed.logZ <- -10.4
logratio <- proposed.logZ-logZ-.5*proposed^2+.5*theta^2
accepted <- log(.7)<min(0,logratio)
if(accepted) {theta <- proposed; logZ <- proposed.logZ}
stopifnot(!accepted,logZ==-10)
print(c(acceptance.prob=exp(min(0,logratio)),theta=theta,retained.logZ=logZ))

Sources

From the CodeSplash reference, entry INF016.