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)& \approx \frac{1}{n}({X}_{1}+\cdots +{X}_{n})\text{}=\text{}{\overline{X}}_{n},\hfill \\ \hfill \text{Var}(X)& \approx \frac{1}{n-1}{\displaystyle \sum _{j=1}^{n}{({X}_{j}-{\overline{X}}_{}}^{}}\hfill \end{array}$

Get *Introduction to Probability* now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.