36 votes
Accepted

Hamiltonian Monte Carlo vs. Sequential Monte Carlo

Hamiltonian Monte Carlo performs well with continuous target distributions with "weird" shapes. It requires the target distribution to be differentiable as it basically uses the slope of the target ...
RemiDav's user avatar
  • 494
16 votes

What is the purpose of "transformed variables" in Stan?

Objects declared in the transformed parameters block of a Stan program are: Unknown but are known given the values of the objects in the ...
Ben Goodrich's user avatar
  • 2,008
15 votes
Accepted

For Hamiltonian Monte Carlo, why does negating the momentum variables result in a symmetric proposal?

One of the reasons why the original construction of Hamiltonian Monte Carlo can be tricky to understand is that it is more restrictive than necessary, if only to simplify the theoretical proofs. In ...
Michael Betancourt's user avatar
14 votes
Accepted

Hamiltonian monte carlo

I believe the most up-to-date source on Hamiltonian Monte Carlo, its practical applications and comparison to other MCMC methods is this 2017-dated review paper by Betancourt: The ultimate ...
Zhubarb's user avatar
  • 8,269
13 votes
Accepted

Hamiltonian Monte Carlo: how to make sense of the Metropolis-Hasting proposal?

The deterministic Hamiltonian trajectories are useful only because they are consistent with the target distribution. In particular, trajectories with a typical energy project onto regions of high ...
Michael Betancourt's user avatar
11 votes
Accepted

Understanding the Typical Set for Markov chain Monte Carlo sampling

$\mathrm{d}q$ is uniform across the entire space and that's the problem! Unfortunately as we consider higher-dimensional spaces out intuition of uniform starts failing us and we end up in conceptual ...
Michael Betancourt's user avatar
11 votes
Accepted

Hamiltonian Monte Carlo (HMC): what's the intuition and justification behind a Gaussian-distributed momentum variable?

It's not so much that we are after $\pi(E)$, it's just that if $\pi(E)$ and $\pi(E|q)$ are dissimilar then our exploration will be limited by our inability to explore all of the relevant energies. ...
Michael Betancourt's user avatar
9 votes
Accepted

Plotting the typical set of a Gaussian distribution

One of the confusing things about concentration of measure is that we're trying to demonstrate deviations away from our naive, low-dimensional intuition. Here that is demonstrated in how the radial ...
Michael Betancourt's user avatar
8 votes
Accepted

How does Hamiltonian Monte Carlo work?

Before answering the question about an intuitive way to think about Hamiltonian Monte Carlo, it's probably best to get a really firm grasp on regular MCMC. Let's set aside the satellite metaphor for ...
Alex I's user avatar
  • 1,123
8 votes
Accepted

MCMC sampling for a model with a multinomial choice--so the parameters need to sum to 1

The problem does not seem to stand with MCMC but with the prior modelling. If the data comes from a Multinomial distribution $$\mathcal D_k(n,p_1,\ldots,p_k)$$ where the probability vector $\mathbf{p}=...
Xi'an's user avatar
  • 106k
7 votes
Accepted

Proposal distribution in Hamiltonian Monte Carlo

The proposal distribution for the original Hamiltonian Monte Carlo algorithm is just a delta function around the final point in the numerical trajectory with the momentum negated, $$K(z' | z) = \delta ...
Michael Betancourt's user avatar
7 votes

Hamiltonian Monte Carlo for dummies

As mentioned in the comments by cwl, bjw and Sycorax, the following resources are useful (I can recommend them from my own experience as well): Statistical rethinking by R. McElreath has a short but ...
Martin Modrák's user avatar
7 votes
Accepted

Reconciling Langevin MC methods as one-step HMC versus as diffusion or brownian motion

The easiest way to understand why Langevin dynamics targets the "correct distribution" is to look at the corresponding Fokker-Planck equation. Let me be more precise. Let us assume that our target ...
thmusic's user avatar
  • 271
6 votes
Accepted

Why does Stan initialize an MCMC chain with a random value generated uniformly from [-2, 2] instead of a random value generated from the prior?

The biggest problem with drawing from the prior is if a user is using a rather flat prior. For example, if a user is using a logistic regression model and they don't want the prior to have much of an ...
Cliff AB's user avatar
  • 21.1k
5 votes
Accepted

Can I use Hamiltionian Monte Carlo when my likelihood is not a direct function of my parameters?

It looks like you might be re-inventing Approximate Bayesian Computation (ABC). The core of ABC is to simulate many synthetic datasets and compare the synthetic data to the observed data based on some ...
Robin Ryder's user avatar
  • 2,086
4 votes

Hamiltonian monte carlo

Hamiltonian Monte Carlo (HMC), originally called Hybrid Monte Carlo, is a form of Markov Chain Monte Carlo with a momentum term and corrections. The "Hamiltonian" refers to Hamiltonian mechanics. ...
Aaron Hall's user avatar
4 votes
Accepted

What does it mean to have a "transient state" or a "transient phase" in an Ising model?

Conventional approaches uses something called single-spin-flip dynamics, depending on acceptance probability, either Metropolis or Glauber dynamics. See IsingLenzMC R package and associated paper ...
patagonicus's user avatar
  • 2,540
3 votes

For Hamiltonian Monte Carlo, what should be done when one of the steps in the leapfrog path yields no solution?

For the most basic version of HMC, the procedure is: using the leapfrog integrator, generate a trajectory $L$ steps long, which approximates Hamiltonian dynamics propose a move to the $L^{\text{th}}...
πr8's user avatar
  • 1,346
3 votes
Accepted

What could lead to this misbehavior for the expected sample size (ESS)?

This is actually not an error - it is possible for the effective sample size to be larger than the actual sample size. This means that your MCMC samples provide more information about the parameter, ...
Anders Gorm's user avatar
2 votes

Proposal distribution in Hamiltonian Monte Carlo

The proposal distribution in Hamiltonian Monte Carlo does not have an explicit form in general. Instead, samples from it are defined operationally: first sample an initial velocity and then move the ...
aripakman's user avatar
  • 165
2 votes
Accepted

Is there an HMC algorithm that estimates a model with noncontinuous parameters?

Currently, no- such a solution does not exist. Core developers on PyMC3 actually addressed this, noting that it's a high impact problem but the solution remains over the horizon. (I'll dig for a ...
jbuddy_13's user avatar
  • 3,020
1 vote

How to diagnose HMC results like r-hat for a Mixture Model?

This is only a partial answer, but in general you can go a long way by adding an order constraint to your model: enforcing $\theta_1 \lt \theta_2 \lt\dots\lt \theta_k$. This is trickier to do if $\...
Eoin's user avatar
  • 8,997
1 vote
Accepted

Regarding Gibbs sampling and HMC in fitting Bayesian model, their differences and advantages

It is incorrect to state that a Gibbs sampler requires the exact densities of the full conditionals. A Gibbs sampling algorithm requires a collection of conditional distributions that correspond to a ...
Xi'an's user avatar
  • 106k
1 vote

Can someone explain how dual averaging helps the No U-Turn Sampler (NUTS) choose step-size adaptively?

I stumbled on this while looking for an answer to my own misunderstanding of the step size algorithm, so your mileage my vary on this answer... With that said, the idea is that the slice sampler is ...
Cory's user avatar
  • 21
1 vote

Can I do HMC with the wrong Hamiltonian?

If I understood well, the critical point in the second step of the HMC algorithm is that the proposal is volume preserving and reversible, but I am free to use another position energy function than ...
πr8's user avatar
  • 1,346
1 vote

Strange substitution in HMC

If $K$ is a Markov kernel(with density $k$) with stationary distribution $P$ (with density $p$), then, if $(X_t)_t$ is a stationary Markov chain associated with $K$, \begin{align*}\mathbb E\left[\frac{...
Xi'an's user avatar
  • 106k
1 vote
Accepted

NUTS algorithm efficient transition kernel

The way to interpret this is as a function that could be applied to any potential $w'$. Specifically, When $\lvert \mathcal C^\mathit{new} \rvert > \lvert \mathcal C^\mathit{old} \rvert$, $T$ ...
Danica's user avatar
  • 24.8k
1 vote

For Hamiltonian Monte Carlo, why does negating the momentum variables result in a symmetric proposal?

Below is only my opinion since I am also a beginner to HMC. I think it's already clear in your desciption. The negation of momentum is unnecessary in practice because we actually only want the ...
nanimonai's user avatar
1 vote
Accepted

How to know if the derivatives exist in Hamiltonian Monte Carlo?

The following is a rough exposition of what the requirement for differentiability on the parameters means here. $U$ involves the log posterior up to an additive constant where $\theta$ are the model ...
conjectures's user avatar
  • 4,226
1 vote

Hamiltonian Monte-Carlo with piecewise differentiable log likelihood

This paper is likely relevant. Abstract: Hamiltonian Monte Carlo (HMC) is a successful approach for sampling from continuous densities. However, it has difficulty simulating Hamiltonian dynamics ...
Alex Coventry's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible