{"url":"/method/metropolis-hastings","slug":"metropolis-hastings","name":"Metropolis Hastings","full_name":"Metropolis Hastings","full_name_withheld":false,"description_markdown":"**Metropolis-Hastings** is a Markov Chain Monte Carlo (MCMC) algorithm for approximate inference. It allows for sampling from a probability distribution where direct sampling is difficult - usually owing to the presence of an intractable integral.\r\n\r\nM-H consists of a proposal distribution $q\\left(\\theta^{'}\\mid\\theta\\right)$ to draw a parameter value. To decide whether $\\theta^{'}$ is accepted or rejected, we then calculate a ratio:\r\n\r\n$$ \\frac{p\\left(\\theta^{'}\\mid{D}\\right)}{p\\left(\\theta\\mid{D}\\right)} $$\r\n\r\nWe then draw a random number $r \\in \\left[0, 1\\right]$ and accept if it is under the ratio, reject otherwise. If we accept, we set $\\theta_{i} = \\theta^{'}$ and repeat.\r\n\r\nBy the end we have a sample of $\\theta$ values that we can use to form quantities over an approximate posterior, such as the expectation and uncertainty bounds. In practice, we typically have a period of tuning to achieve an acceptable acceptance ratio for the algorithm, as well as a warmup period to reduce bias towards initialization values.\r\n\r\nImage: [Samuel Hudec](https://static1.squarespace.com/static/52e69d46e4b05a145935f24d/t/5a7dbadcf9619a745c5b2513/1518189289690/Stan.pdf)","description_state":"present","introduced_year":null,"introduced_by":{"title":null,"paper":null,"first_author":null,"n_authors":0,"url_abs":null,"archive_paper_url":null},"source":{"url":null,"title":null,"url_on_a_paper_host":false},"code_snippet_url":null,"code_snippet_url_on_a_code_host":false,"categories":[{"area":"General","area_id":"general","collection":"Markov Chain Monte Carlo","url":"/methods/category/markov-chain-monte-carlo","pwc_aliases":[]}],"n_papers_tagged":10,"archive_num_papers":10,"papers_newest_first":[{"paper":null,"title":"AdvNF: Reducing Mode Collapse in Conditional Normalising Flows using Adversarial Learning","date":"2024-01-29","arxiv_id":"2401.15948","n_code_links":0,"syntology":null},{"paper":null,"title":"Binary classification based Monte Carlo simulation","date":"2023-07-29","arxiv_id":"2307.16035","n_code_links":0,"syntology":null},{"paper":"/paper/data-subsampling-for-bayesian-neural-networks","title":"Data Subsampling for Bayesian Neural Networks","date":"2022-10-17","arxiv_id":"2210.09141","n_code_links":1,"syntology":null},{"paper":null,"title":"A Two-step Metropolis Hastings Method for Bayesian Empirical Likelihood Computation with Application to Bayesian Model Selection","date":"2022-09-02","arxiv_id":"2209.01269","n_code_links":0,"syntology":null},{"paper":null,"title":"Mix and Match: Learning-free Controllable Text Generationusing Energy Language Models","date":"2021-11-16","arxiv_id":null,"n_code_links":0,"syntology":null},{"paper":"/paper/subsampling-generative-adversarial-networks","title":"Subsampling Generative Adversarial Networks: Density Ratio Estimation in Feature Space with Softplus Loss","date":"2019-09-24","arxiv_id":"1909.10670","n_code_links":1,"syntology":{"ran":0,"of":1,"unverified":1,"pointer_only":0}},{"paper":null,"title":"Hawkes Processes with Stochastic Excitations","date":"2016-09-22","arxiv_id":"1609.06831","n_code_links":0,"syntology":null},{"paper":null,"title":"C3: Lightweight Incrementalized MCMC for Probabilistic Programs using Continuations and Callsite Caching","date":"2015-09-07","arxiv_id":"1509.02151","n_code_links":0,"syntology":null},{"paper":null,"title":"Neural Adaptive Sequential Monte Carlo","date":"2015-06-10","arxiv_id":"1506.03338","n_code_links":0,"syntology":null},{"paper":null,"title":"GPS-ABC: Gaussian Process Surrogate Approximate Bayesian Computation","date":"2014-01-13","arxiv_id":"1401.2838","n_code_links":0,"syntology":null}],"papers_shown":10,"tasks":[{"task":"/task/attribute","name":"Attribute","papers":1},{"task":"/task/bayesian-inference","name":"Bayesian Inference","papers":1},{"task":"/task/binary-classification","name":"Binary Classification","papers":1},{"task":"/task/classification-1","name":"Classification","papers":1},{"task":"/task/density-ratio-estimation","name":"Density Ratio Estimation","papers":1},{"task":"/task/federated-learning","name":"Federated Learning","papers":1},{"task":"/task/image-generation","name":"Image Generation","papers":1},{"task":"/task/language-modeling","name":"Language Modeling","papers":1},{"task":"/task/language-modelling","name":"Language Modelling","papers":1},{"task":"/task/model-selection","name":"Model Selection","papers":1},{"task":"/task/normalising-flows","name":"Normalising Flows","papers":1},{"task":"/task/probabilistic-programming","name":"Probabilistic Programming","papers":1},{"task":"/task/style-transfer","name":"Style Transfer","papers":1},{"task":"/task/text-generation","name":"Text Generation","papers":1},{"task":"/task/variational-inference","name":"Variational Inference","papers":1}],"tasks_shown":15,"n_tasks":15,"usage_by_year":[{"year":"2014","papers":1},{"year":"2015","papers":2},{"year":"2016","papers":1},{"year":"2019","papers":1},{"year":"2021","papers":1},{"year":"2022","papers":2},{"year":"2023","papers":1},{"year":"2024","papers":1}],"row_source":"methods_table","archive":{"source":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","archive_url":"https://paperswithcode.com/method/metropolis-hastings"},"syntology_read_at":"2026-09-24T18:15:14+00:00"}