This page implements a
Hamiltonian Monte Carlo algorithm to sample from either a long, skinny normal distribution or a round Cauchy distribution. The algorithm works by shooting a particle in a random direction along a surface defined by the target likelihood function. As it goes "uphill" to regions of lower probability, the particle slows down, and as it goes "downhill" to regions of higher probability it speeds up. After computing the trajectory for 20 steps, we either accept or reject the particle's position as our new starting position: we reject if the location is too unlikely
or if the particle is moving too fast.