CodingTrain / CodingTrain/Suggestion-Box

Markov Chain Monte Carlo Sampling

Open
#1,378 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

[MCMC](https://en.wikipedia.org/wiki/Markov_chain_Monte_Carlo) is a collection of algorithms, that iteratively create a markov chain that approximates (or samples) an underlying distribution. Another way of thinking about it, is that it is an algorithm that randomly walks along the most representative portions of a distribution (as opposed to random sampling approaches). The interesting aspect of this is that the distribution can be ANYTHING. It can be an actual mathematical distribution or a geometric space or something more abstract such as a 'cognitive distribution' of what constitutes say a giraffe or a dog (see last example linked below).

There are many types of MCMC algorithms, but one of the simplest ones (Metropolis-Hastings) works by simply comparing the point probability of the current position with a new proposed position sampled from a distribution (usually gaussian) centered around the current position. Then it uses the ratio of the two probabilities to decide whether to stick with the old position or jump to the new position.

Some visualization examples:
- MCMC sampling a banana-shaped distribution: [link](https://chi-feng.github.io/mcmc-demo/app.html#RandomWalkMH,banana). You can check other distributions and also more advanced variations of MCMC that sample the space more efficiently.
- MCMC sampling the surface of a 3D cow: [link](https://www.youtube.com/watch?v=0MzH69hFdkE). This illustrates that you can use any distribution you want (in this case the perpendicular distance from the surface).
- MCMC sampling a b/w sketch to fill the canvas with Bezier curves: [link](https://www.reddit.com/r/creativecoding/comments/bvk0h8/bezier_curves_with_markov_chain_monte_carlo/). Another more educational example [link](https://www.youtube.com/watch?v=I4xoX7lJbL8)
- MCMC where people are actually used to decide what the next step should be, in order to sample the cognitive distribution of animal sketches: [link](https://papers.nips.cc/paper/3214-markov-chain-monte-carlo-with-people.pdf). Scroll to page 7 to see the results.

- A much more complex sequential MCMC algorithm to generate a 3D spaceship: [link](https://dritchie.github.io/web-procmod/).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.