Skip to content

revised NUTS description; fixes #436#966

Open
bob-carpenter wants to merge 1 commit into
masterfrom
nuts-algo-issue-436
Open

revised NUTS description; fixes #436#966
bob-carpenter wants to merge 1 commit into
masterfrom
nuts-algo-issue-436

Conversation

@bob-carpenter

Copy link
Copy Markdown
Member

This revises the description of the HMC and NUTS algorithms with corrected and added citations.

Submission Checklist

  • Builds locally
  • [n/a] New functions marked with <<{ since VERSION }>>
  • Declare copyright holder and open-source license: see below

Summary

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):

Simons Foundation

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

@jgabry jgabry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating this. No major suggestions. I found a few typos and had a couple of questions about the math. I hope I didn't miss anything else!

Comment on lines +148 to +157
\begin{align}
\rho &\leftarrow
\rho \, + \, \dfrac{\epsilon}{2} \, \nabla \, p(\theta \mid y)
\\[6pt]
\theta & \leftarrow
& \theta \, + \, \epsilon \, M^{-1} \, \rho
\theta &\leftarrow
\theta \, + \, \epsilon \, M^{-1} \, \rho
\\[6pt]
\rho & \leftarrow
& \rho \, - \, \frac{\epsilon}{2} \frac{\partial V}{\partial \theta}.
\end{array}
$$
\rho &\leftarrow
\rho \, - \, \dfrac{\epsilon}{2} \, \nabla \, p(\theta \mid y)
\end{align}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple things I noticed here:

  • p(theta | y) should be log(p(theta|y)) on lines 150 and 156, right?

  • I think both momentum half-steps should have the same sign, right? You use + for one and - for the other. I think both should be + here if you use log(p(theta|y)) instead of V(theta).

$$
\min\left(
1,
\dfrac{p(\theta^*, \rho)}{p(\theta, \rho)}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\dfrac{p(\theta^*, \rho)}{p(\theta, \rho)}
\dfrac{p(\theta^*, \rho^*)}{p(\theta, \rho)}

T(\rho) = - \log p(\rho \mid M).
$$
V(\theta) = - \log p(\theta)
Here, $\log p(\rho \mid M) = \textrm{MultiNormal}(\rho \mid 0, M)$,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here you either need to drop log from the LHS or add it to the RHS

If the inverse metric $M^{-1}$ is a poor estimate of the posterior covariance,
the step size $\epsilon$ must be kept small to maintain arithmetic
precision. This would lead to a large $L$ to compensate.
If the inverse metric $M^{-1}$ is a poor estimate of the local

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the notation you've been using in this chapter, should this be M (not M^{-1}) that's an estimate of the curvature?

the same amount of work to generate each new roughly independent
draw.

Warmup times being vast only holds when the posterior is log concave,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Warmup times being vast only holds when the posterior is log concave,
Warmup times being fast only holds when the posterior is log concave,

where the term

The two terms into which it separates are treated in
the Hamiltonian dynamics as a a potential energy function defined by

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the Hamiltonian dynamics as a a potential energy function defined by
the Hamiltonian dynamics as a potential energy function defined by

value is selected via multinomial sampling with a bias toward the
second half of the steps in the trajectory @Betancourt:2016.^[Stan previously used slice sampling along the trajectory, following the original NUTS paper of @Hoffman-Gelman:2014.]
determined by the parameters drawn in the last iteration. Like HMC,
it starts by Gibbs sampling a a random momentum vector with covariance

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it starts by Gibbs sampling a a random momentum vector with covariance
it starts by Gibbs sampling a random momentum vector with covariance

@Betancourt-Girolami:2013 into the notation of @GelmanEtAl:2013.

method that scales well in dimension due to its use of gradients of
the the log density function being sampled. It uses an approximate

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the the log density function being sampled. It uses an approximate
the log density function being sampled. It uses an approximate

consisting of the sum of the densities in the new doubling divided by
the sum of the densities in the current trajectory. Because these are
the same length and the Hamiltonian should be preserved, the
probabability of jumping to the new doubling is close to 1 when the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
probabability of jumping to the new doubling is close to 1 when the
probability of jumping to the new doubling is close to 1 when the

the sum of the densities in the current trajectory. Because these are
the same length and the Hamiltonian should be preserved, the
probabability of jumping to the new doubling is close to 1 when the
leapfrog algoritm is stable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
leapfrog algoritm is stable.
leapfrog algorithm is stable.

U-turn arises when an infinitesimal extension of the trajectory has
the ends moving closer to each other. It also stops doubling if a
maximum number of doublings is achieved (maximum 10 by default, for a
total of 1024 leapfrog steps).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
total of 1024 leapfrog steps).
total of 1024 leapfrog steps, including the initial state).

It's really 1023 steps, right? 1024 including the initial state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants