<s>
The	O
Hamiltonian	B-Algorithm
Monte	I-Algorithm
Carlo	I-Algorithm
algorithm	O
(	O
originally	O
known	O
as	O
hybrid	B-Algorithm
Monte	I-Algorithm
Carlo	I-Algorithm
)	O
is	O
a	O
Markov	B-General_Concept
chain	I-General_Concept
Monte	I-General_Concept
Carlo	I-General_Concept
method	I-General_Concept
for	O
obtaining	O
a	O
sequence	O
of	O
random	O
samples	O
which	O
converge	B-Algorithm
to	O
being	O
distributed	O
according	O
to	O
a	O
target	O
probability	O
distribution	O
for	O
which	O
direct	O
sampling	O
is	O
difficult	O
.	O
</s>
<s>
This	O
sequence	O
can	O
be	O
used	O
to	O
estimate	O
integrals	B-Algorithm
with	O
respect	O
to	O
the	O
target	O
distribution	O
(	O
expected	O
values	O
)	O
.	O
</s>
<s>
Hamiltonian	B-Algorithm
Monte	I-Algorithm
Carlo	I-Algorithm
corresponds	O
to	O
an	O
instance	O
of	O
the	O
Metropolis	B-Algorithm
–	I-Algorithm
Hastings	I-Algorithm
algorithm	I-Algorithm
,	O
with	O
a	O
Hamiltonian	O
dynamics	O
evolution	O
simulated	O
using	O
a	O
time-reversible	O
and	O
volume-preserving	O
numerical	O
integrator	O
(	O
typically	O
the	O
leapfrog	B-Algorithm
integrator	I-Algorithm
)	O
to	O
propose	O
a	O
move	O
to	O
a	O
new	O
point	O
in	O
the	O
state	O
space	O
.	O
</s>
<s>
Compared	O
to	O
using	O
a	O
Gaussian	O
random	O
walk	O
proposal	O
distribution	O
in	O
the	O
Metropolis	B-Algorithm
–	I-Algorithm
Hastings	I-Algorithm
algorithm	I-Algorithm
,	O
Hamiltonian	B-Algorithm
Monte	I-Algorithm
Carlo	I-Algorithm
reduces	O
the	O
correlation	O
between	O
successive	O
sampled	O
states	O
by	O
proposing	O
moves	O
to	O
distant	O
states	O
which	O
maintain	O
a	O
high	O
probability	O
of	O
acceptance	O
due	O
to	O
the	O
approximate	O
energy	O
conserving	O
properties	O
of	O
the	O
simulated	O
Hamiltonian	O
dynamic	O
when	O
using	O
a	O
symplectic	B-Algorithm
integrator	I-Algorithm
.	O
</s>
<s>
The	O
reduced	O
correlation	O
means	O
fewer	O
Markov	O
chain	O
samples	O
are	O
needed	O
to	O
approximate	O
integrals	B-Algorithm
with	O
respect	O
to	O
the	O
target	O
probability	O
distribution	O
for	O
a	O
given	O
Monte	B-Algorithm
Carlo	I-Algorithm
error	O
.	O
</s>
<s>
In	O
1996	O
,	O
Radford	O
M	O
.	O
Neal	O
showed	O
how	O
the	O
method	O
could	O
be	O
used	O
for	O
a	O
broader	O
class	O
of	O
statistical	O
problems	O
,	O
in	O
particular	O
artificial	B-Architecture
neural	I-Architecture
networks	I-Architecture
.	O
</s>
<s>
However	O
,	O
the	O
burden	O
of	O
having	O
to	O
supply	O
gradients	O
of	O
the	O
respective	O
densities	O
delayed	O
the	O
wider	O
adoption	O
of	O
the	O
algorithm	O
in	O
statistics	O
and	O
other	O
quantitative	O
disciplines	O
,	O
until	O
in	O
the	O
mid-2010s	O
the	O
developers	O
of	O
Stan	B-Application
implemented	O
HMC	O
in	O
combination	O
with	O
automatic	B-Algorithm
differentiation	I-Algorithm
.	O
</s>
<s>
where	O
and	O
are	O
the	O
th	O
component	O
of	O
the	O
position	O
and	O
momentum	B-Algorithm
vector	O
respectively	O
and	O
is	O
the	O
Hamiltonian	O
.	O
</s>
<s>
First	O
,	O
a	O
random	O
Gaussian	O
momentum	B-Algorithm
is	O
drawn	O
from	O
.	O
</s>
<s>
Next	O
,	O
the	O
particle	O
will	O
run	O
under	O
Hamiltonian	O
dynamics	O
for	O
time	O
,	O
this	O
is	O
done	O
by	O
solving	O
the	O
Hamilton	O
's	O
equations	O
numerically	O
using	O
the	O
leap	B-Algorithm
frog	I-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
The	O
leap	B-Algorithm
frog	I-Algorithm
algorithm	I-Algorithm
is	O
an	O
approximate	O
solution	O
to	O
the	O
motion	O
of	O
non-interacting	O
classical	O
particles	O
.	O
</s>
<s>
One	O
way	O
to	O
move	O
the	O
system	O
towards	O
a	O
thermodynamic	O
equilibrium	O
distribution	O
is	O
to	O
change	O
the	O
state	O
of	O
the	O
particles	O
using	O
the	O
Metropolis	B-Algorithm
–	I-Algorithm
Hastings	I-Algorithm
.	O
</s>
<s>
So	O
first	O
,	O
one	O
applies	O
the	O
leap	O
frog	O
step	O
,	O
then	O
a	O
Metropolis-Hastings	B-Algorithm
step	O
.	O
</s>
<s>
Let	O
and	O
be	O
the	O
position	O
and	O
momentum	B-Algorithm
of	O
the	O
forward	O
particle	O
respectively	O
.	O
</s>
