Monte Carlo Method

Definition (Monte Carlo Method)

Monte Carlo methods are a class of computational algorithms that rely on repeated random sampling to obtain numerical results.

Basic Problem of Monte Carlo

Given a pmf/pdf π(x)\pi(x), and a function f(x)f(x), estimate μ=f(x)π(x)dx\mu=\int f(x)\pi(x)dx where \int is replaced by \sum for discrete components.

Equivalently

Given XπX\sim \pi find μ=E[f(x)]\mu=E[f(x)].

Naive Monte Carlo

  1. Draw i.i.d samples X1,,XnX_1,\cdots,X_n from π(x)\pi(x).

  2. Estimate μ\mu by the sample average μ^R=1Ri=1Rf(Xi)\hat\mu_R=\frac{1}{R}\sum^R_{i=1}f(X_i)

    Justifications:

  3. SLLN: μ^f(x)π(x)dx\hat\mu\to\int f(x)\pi(x)dx w.p.1.

  4. Decay of Variance: Var(μ^R)=Var(f(X1))RR0Var(\hat\mu_R)=\frac{Var(f(X_1))}{R}\xrightarrow{R\to\infty}0

    1. Where Var(f(X1))=Var^(f(X1)RVar(f(X_1))=\frac{\hat {Var}(f(X_1)}{R} with Var^(f(X1))=1R1i=1R(f(xi)μ^R)2\hat{Var}(f(X_1)) = \frac{1}{R-1}\sum_{i=1}^R(f(x_i)-\hat\mu_R)^2 is the Sample Variance

Generating Random Variables

The first step of the Monte Carlo is generating RVs. Once such method is the inversion method:

Lemma (Inversion Method)

Assume that we are able to generate i.i.d. random variables which is uniformly distributed between (0,1)(0,1). Let UUnif(0,1)U\sim Unif(0,1) and FF be a one-dimensional cdf. Denote X=F1(U), where F1(u)=inf{xR: F(x)u}X=F^{-1}(U), \ \text{where }F^{-1}(u)=\inf\{x\in\mathbb{R}: \ F(x)\ge u\} Then XX has the distribution F.

  • Consider a discrete distribution with finite support on a1<<aKa_1<\cdots<a_K, and π(ai)=pi, for 1iK\pi(a_i)=p_i, \ \text{for } 1\le i\le K where i=1Kpi=1\sum_{i=1}^Kp_i=1.
  • Generate UUnif(0,1)U\sim Unif(0,1), and let F1(U)=X=ai    j=1i1pj<Uj=1ipjF^{-1}(U)=X=a_i \iff \sum_{j=1}^{i-1}p_j< U\le\sum_{j=1}^ip_j