{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/mcmc-using-hamiltonian-dynamics","title":"MCMC using Hamiltonian dynamics","arxiv_id":"1206.1901","date":"2012-06-09","proceeding":null,"authors":["Radford M. Neal"],"abstract":"Hamiltonian dynamics can be used to produce distant proposals for the Metropolis algorithm, thereby avoiding the slow exploration of the state space that results from the diffusive behaviour of simple random-walk proposals. Though originating in physics, Hamiltonian dynamics can be applied to most problems with continuous state spaces by simply introducing fictitious \"momentum\" variables. A key to its usefulness is that Hamiltonian dynamics preserves volume, and its trajectories can thus be used to define complex mappings without the need to account for a hard-to-compute Jacobian factor - a property that can be exactly maintained even when the dynamics is approximated by discretizing time. In this review, I discuss theoretical and practical aspects of Hamiltonian Monte Carlo, and present some of its variations, including using windows of states for deciding on acceptance or rejection, computing trajectories using fast approximations, tempering during the course of a trajectory to handle isolated modes, and short-cut methods that prevent useless trajectories from taking much computation time.","url_abs":"http://arxiv.org/abs/1206.1901v1","url_pdf":"http://arxiv.org/pdf/1206.1901v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"links_only","authors_date_abstract":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license), from the Kaggle arXiv metadata snapshot of 2026-09-12"},"code_links":[{"paper_slug":"mcmc-using-hamiltonian-dynamics","repo_url":"https://github.com/LMikeH/ocbnn-lmikh","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"mcmc-using-hamiltonian-dynamics","repo_url":"https://github.com/chang-ml-thu/FGH-flow","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":{"status":"ok"}},{"paper_slug":"mcmc-using-hamiltonian-dynamics","repo_url":"https://github.com/ermongroup/a-nice-mc","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":{"status":"unanswered"}},{"paper_slug":"mcmc-using-hamiltonian-dynamics","repo_url":"https://github.com/gpapamak/bayesian_neural_networks_demo","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":null},{"paper_slug":"mcmc-using-hamiltonian-dynamics","repo_url":"https://github.com/jiamings/a-nice-mc","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":{"status":"unanswered"}},{"paper_slug":"mcmc-using-hamiltonian-dynamics","repo_url":"https://github.com/ricvalp/aisampler","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"jax","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"mcmc-using-hamiltonian-dynamics","repo_url":"https://github.com/siddancha/samplevis","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":{"status":"ok"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=1206.1901","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1206.1901"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/LMikeH/ocbnn-lmikh","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ricvalp/aisampler","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/chang-ml-thu/FGH-flow","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/siddancha/samplevis","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/gpapamak/bayesian_neural_networks_demo","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ermongroup/a-nice-mc","reach":{"status":"unanswered"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jiamings/a-nice-mc","reach":{"status":"unanswered"}}],"summary":{"unverified":17},"by_repo_kind":{"listed":{"samples":17,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"c3e338a6c8c2e3c4","entry":"U","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/logistic_regression/densities.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/logistic_regression/densities.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c3e338a6c8c2e3c4"}},{"code_sha256_prefix":"69a7db05762d9394","entry":"create_henon_flow","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/kernels/HenonFlow.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/kernels/HenonFlow.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"69a7db05762d9394"}},{"code_sha256_prefix":"4646bb82ede9bc1e","entry":"create_simple_discriminator_without_kernel","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/discriminators/utils.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/discriminators/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4646bb82ede9bc1e"}},{"code_sha256_prefix":"022942a1868fa9bb","entry":"ess","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/sampling/metrics.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/sampling/metrics.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"022942a1868fa9bb"}},{"code_sha256_prefix":"e4c7f98ecfb16a0c","entry":"gelman_rubin_r","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/sampling/metrics.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/sampling/metrics.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e4c7f98ecfb16a0c"}},{"code_sha256_prefix":"46871977f6995869","entry":"get_discriminator_function","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/discriminators/utils.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/discriminators/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"46871977f6995869"}},{"code_sha256_prefix":"90fddff06eaaf1ba","entry":"get_params_from_checkpoint","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/kernels/utils.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/kernels/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"90fddff06eaaf1ba"}},{"code_sha256_prefix":"7cfa38bfca9e0f43","entry":"hmc_kernel","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/sampling/hamiltonian_monte_carlo.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/sampling/hamiltonian_monte_carlo.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7cfa38bfca9e0f43"}},{"code_sha256_prefix":"9e160366deb59347","entry":"hmc_proposal","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/sampling/hamiltonian_monte_carlo.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/sampling/hamiltonian_monte_carlo.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9e160366deb59347"}},{"code_sha256_prefix":"f5d2f37f8001b5d1","entry":"lag_s_autocorrelation","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/sampling/metrics.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/sampling/metrics.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f5d2f37f8001b5d1"}},{"code_sha256_prefix":"85bd9d4d7c767644","entry":"leapfrog_step","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/sampling/hamiltonian_monte_carlo.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/sampling/hamiltonian_monte_carlo.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"85bd9d4d7c767644"}},{"code_sha256_prefix":"0bd227a6783875bd","entry":"normal","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/logistic_regression/densities.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/logistic_regression/densities.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0bd227a6783875bd"}},{"code_sha256_prefix":"3d60559d8ce91f43","entry":"plot_discriminator","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/discriminators/utils.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/discriminators/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3d60559d8ce91f43"}},{"code_sha256_prefix":"6f27316046641935","entry":"plot_histograms2d_logistic_regression","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/logistic_regression/utils.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/logistic_regression/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6f27316046641935"}},{"code_sha256_prefix":"278f5bed5e830df4","entry":"plot_histograms_logistic_regression","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/logistic_regression/utils.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/logistic_regression/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"278f5bed5e830df4"}},{"code_sha256_prefix":"0bc0f66d15c19a63","entry":"plot_logistic_regression_samples","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/logistic_regression/utils.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/logistic_regression/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0bc0f66d15c19a63"}},{"code_sha256_prefix":"543ac1fdfab44708","entry":"sigma","repo":"ricvalp/aisampler","repo_kind":"listed","path":"aisampler/logistic_regression/densities.py","file_url":"https://github.com/ricvalp/aisampler/blob/HEAD/aisampler/logistic_regression/densities.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"543ac1fdfab44708"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}