Chapter 12

# Markov chain Monte Carlo

We have seen throughout this book that simulation is a powerful technique in probability. If you canât convince your friend that it is a good idea to switch doors in the Monty Hall problem, in one second you can simulate playing the game a few thousand times and your friend will just see that switching succeeds about 2/3 of the time. If youâre unsure how to calculate the mean and variance of an r.v. X but you know how to generate i.i.d. draws X1, X2, ... , Xn from that distribution, you can approximate the true mean and true variance using the sample mean and sample variance of the simulated draws:

$\begin{array}{cc}\hfill E(X)& \xe2\x89\x88\frac{1}{n}({X}_{1}+\xe2\x8b\xaf+{X}_{n})\text{}=\text{}{\stackrel{\xc2\xaf}{X}}_{n},\hfill \\ \hfill \text{Var}(X)& \xe2\x89\x88\frac{1}{n\xe2\x88\x921}{\displaystyle \underset{j=1}{\overset{n}{\xe2\x88\x91}}{}^{}}\hfill \end{array}$

Get *Introduction to Probability* 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.