K X Au
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Reparametrising HMC We have a variable $q$ whose distribution has covariance $\Sigma$. You can imagine a Gaussian for simplicity if you'd like. In HMC, the usual choice for the distribution of the auxiliary variable $p$ would be the isotropic Gaussian (with mass matrix $M = I$). To sample efficiently, we would like to either 1. sample a whitened $\tilde q$ with $p \sim N(0,I)$ then transform the samples back to $q$, or 2. sample $q$ directly, with a well-chosen $M$ so that $p \sim N(0,M)$ to produce efficient proposals. In this note, we show that approach 1 gives the same result as approach 2. ## Position variable Let us first establish the relationship between these transformed and non-transformed variables. We can transform our original variable with the following relation $$q = L \tilde q \quad \text{or} \quad \tilde q = L^{-1} q,$$ where $L L^T = \Sigma$ from a Cholesky decomposition or otherwise. The whitened $\tilde q$ should hopefully resemble an isotropic Gaussian. ## Momentum variable Given knowledger of $\Sigma$ or some approximation of it, from Neal's paper on HMC (page 22) we know the best choice for mass matrix is $M = \Sigma^{-1}$. This intuition for this choice is that a small mass in the direction of large variance allows for better exploration (see Stuart's Hilbert space HMC paper). From our previous decomposition of $\Sigma$, we have $\Sigma^{-1} = (LL^T)^{-1} = L^{-T} L^{-1} = L^{-T} (L^{-T})^T$. If you'd like, you can call $C = L^{-T}$ and say that $M = C C^T$. Here, I will stick to just using $L$. Then, the momentum transform reads $$ p = L^{-T} \tilde p \quad or \quad \tilde p = L^T p.$$ ## Target density and gradient We want that both $q$ and $\tilde q$ to maintain the same proportion in the respective target density functions, that is to say $$ \pi(q) =\pi(L \tilde q) \propto \tilde \pi (\tilde q).$$ The constant factor can be ignored as they cancel out in the Hamiltonian (and so acceptance probability) calculations. For a Gaussian target, we have $$-\log \pi(q) = \frac{1}{2} q^T \Sigma^{-1} q = \frac{1}{2} (L^{-1} q)^T (L^{-1}q) = \frac{1}{2} \tilde q^T \tilde q = -\log \tilde \pi(\tilde q).$$ Similarly, we want both gradients to check out. Using basic chain rule, we have $$- \nabla_q \log \pi = - \nabla_q \log \tilde \pi =- \nabla_\tilde q \log \tilde \pi \, \nabla_q \,\tilde q = (L^{-T})(-\nabla_\tilde q \log \tilde \pi)$$ Note the extra $L^{-T}$ term before the whitened target gradient. This means we should not expect the gradient values to match if we naively take the gradient from the abovementioned target. Nevertheless, we do not require them to be the same, as they are not involved in the Metropolis-Hastings decision. We will see that this all works out nicely in the leapfrog integrator. ## Leapfrog Integrator Let us check that in each step of the leapfrog integrator, both approaches agree with each other. We first look at the momentum half-step update \begin{align} p_{1/2} &= p_0 - \frac{\epsilon}{2} \nabla_q \log \pi (q_0) \\ \Rightarrow p_{1/2} &= p_0 - \frac{\epsilon}{2} (L^{-T}) \nabla_{\tilde q} \log \pi (\tilde q_0) \\ \Rightarrow L^T p_{1/2} &= L^T p_0 - \frac{\epsilon}{2} \nabla_{\tilde q} \log \pi (\tilde q_0)\\ \Rightarrow \tilde p_{1/2} &= \tilde p_0 - \frac{\epsilon}{2} \nabla_{\tilde q} \log \pi (\tilde q_0) \end{align} And so, we see that the momentum half-step update in approach 1 implies the momentum half-step update in approach 2. You can reverse the derivation to see that they are equivalent. Next, we consider the position full-step update \begin{align} q_1 &= q_0 + \epsilon \, \Sigma \, p_{1/2} \\ \Rightarrow q_1 &= q_0 + \epsilon \, \Sigma \, L^{-T} \tilde p_{1/2} \\ \Rightarrow L^{-1} q_1 &= L^{-1} q_0 + \epsilon \, L^{-1} \Sigma \, L^{-T} \tilde p_{1/2} \\ \Rightarrow L^{-1} q_1 &= L^{-1} q_0 + \epsilon \, L^{-1}(L L^T) \, L^{-T} \tilde p_{1/2} \\ \Rightarrow \tilde q_1 &= \tilde q_0 + \epsilon \, \tilde p_{1/2}. \\ \end{align} The last momentum half-step is the same as the first. Thus, we have shown that for both approaches, at every step of the leapfrog integrators agree in the sense that we can transform between approaches and recover either parametrisation. ## Bounce operator In the bouncy sampler, there is an additional bounce operator. We label $\lambda := -\nabla_q \log \pi (q)$ and $\tilde \lambda = -\nabla_{\tilde q} \log \tilde \pi (\tilde q)$. From before, we know that $L^T \lambda = \tilde \lambda$. We start from the whitened parametrisation (I find it easier). The reflection operator reads \begin{align} \tilde R(\tilde \lambda, \tilde p) &= \tilde p - 2\frac{\langle \tilde \lambda, \tilde p \rangle}{ \langle \tilde \lambda, \tilde \lambda \rangle} \tilde \lambda \\ &= L^{T} p - 2\frac{\langle L^{T} \lambda, L^{T} p \rangle}{ \langle L^{T} \lambda, L^{T} \lambda \rangle} L^{T} \lambda \\ &= L^{T} \Bigg\{ p - 2\frac{\langle L^{T} \lambda, L^{T} p \rangle}{ \langle L^{T} \lambda, L^{T} \lambda \rangle} \lambda \Bigg\} \\ &= L^{T} \Bigg\{ p - 2\frac{ \lambda^T L L^T p }{ \lambda^T L L^T \lambda} \lambda \Bigg\} \\ &= L^{T} \Bigg\{ p - 2\frac{ \lambda^T \Sigma p }{ \lambda^T \Sigma \lambda} \lambda \Bigg\} \\ &= L^{T} \Bigg\{ p - 2\frac{ \langle \lambda, \Sigma p \rangle}{ \langle \Sigma \lambda, \lambda \rangle} \lambda \Bigg\} \\ &= L^{T} \Bigg\{ p - 2\frac{ \langle \Sigma \lambda, p \rangle}{ \langle \Sigma \lambda, \lambda \rangle} \lambda \Bigg\}.\\ &:= L^{T} R(\lambda, p).\\ \end{align} Note that the penultimate equality is possible since $\Sigma$ is symmetric. The reflection operator produces a momentum (or direction), and we see that $\tilde R = L^T R$ does obey the momentum transformation.

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully