Example of Metropolis-Hastings sampling

We can implement this algorithm to find the posterior distribution P(A|B) given the product of P(B|A) and P(A), without considering the normalizing constant that requires a complex integration.

Let's suppose that:

Therefore, the resulting g(x) is:

To solve this problem, we adopt the random walk Metropolis-Hastings, which consists of choosing q ∼ Normal(μ=x(t-1)). This choice allows simplifying the value α, because the two terms q(x(t-1)|x') and q(x'|x(t-1)) are equal (thanks to the symmetry around the ...

Get Mastering Machine Learning Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.