Further reading on MCMC

To educate yourself more about the details of Markov chain Monte Carlo, you should check out this vignette from Michael Betancourt. For more on how Stan’s HMC sampler works, I recommend his conceptual introduction to Hamiltonian Monte Carlo and his lecture on that topic.