# Bayesian Estimation of Simultaneous Regression Quantiles Using Hamiltonian Monte Carlo
## 3 Hamiltonian Monte Carlo  
Markov chain Monte Carlo (MCMC) was employed to simulate state distributions for an idealized molecular system. An alternative molecular dynamics approach was implemented, featuring deterministic molecular movement adhering to [PERSON]'s law of motion elegantly formalized as Hamiltonian dynamics. The inaugural MCMC algorithm incorporating Hamiltonian dynamics was the static HMC [36]. HMC [37; 38] has favorable properties in complex models. The sampling from Metropolis-Hastings [39] and Gibbs [40] relies on random samples from an easy-to-sample distribution of proposals or conditional densities. In complex problems, these algorithms may not give good results; for example, random walks have difficulty \"exploring\" distributions. The purpose of the HMC algorithm is to use a different kind of sampling that is expected to more effectively \"explore\" the posterior distribution. Moreover, the HMC requires the differentiability of the density function. According to [41], HMC's strength is its ability to explore high-dimensional parameter spaces more effectively. By utilizing gradient information from the posterior distribution, HMC avoids the random-walk nature of traditional MCMC methods. This results in a faster convergence, lower autocorrelation, and enhanced mixing, which provides more accurate estimates of the posterior distribution using fewer samples (a simple example is presented in Appendix B). In addition, HMC outperforms Gibbs sampling and Metropolis-Hastings by efficiently exploring high-dimensional target distributions without succumbing to random walk behavior or sensitivity to correlated parameters [42]. Beyond its ability to manage complex and multimodal distributions, HMC's versatility extends to diverse fields, making it a useful tool in areas such as machine learning, physics, and more. HMC, essentially a variant of Metropolis-Hastings, draws inspiration from a physical analogy with a distinct approach to proposal generation. The dynamics can be visualized in two dimensions, such as that of a frictionless puck that slides across a variable-height surface. The state of this system comprises the puck position, provided by a two-dimensional vector \(z\), and the puck momentum, provided by a two-dimensional vector \(p\) (its mass times its speed). The puck's potential energy, \(U(z)\), is proportional to its present position's ground height, while its kinetic energy, \(K(p)\), is equal to \(p^{2}/(2m)\), where \(m\) is the puck's mass. The puck passes at a steady velocity, equivalent to \(p/m\), at a level part of the surface. The potential energy for these factors forms the negative logarithm of the probability density. This physical analogy serves as a conceptual tool for understanding the dynamic interplay between position and momentum in the system, providing valuable insight into the foundational principles of the HMC algorithm. Subsequently, in HMC applications, Hamiltonian functions are commonly employed and can be represented as follows:  
\[H(z,p)=U(z)+K(p) \tag{8}\]  
Here, \(U(z)\) is called potential energy and is defined as minus the distribution log probability density for \(z\) (\(U(z)=-\log(l(x|z)\times g(z))\) that we want to sample, plus any useful constant. \(K(p)\) is called kinetic energy and is generally described as  
\[K(p)=p^{T}M^{-1}p/2 \tag{9}\]  
Here, \(M\) is a symmetric, positive-definite \"mass matrix\". After identifying our potential and kinetic energy functions and introducing momentum variables that are relevant to our position variables, we can simulate a Markov chain in which each iteration takes place:  
* Randomly sample \(K(p)\) momentum variables, regardless of present position;
* Update Metropolis using simulated Hamiltonian dynamics (implemented by the leapfrog method, for example).