Monte Carlo Method

Definition

Monte carlo method is a stochastic approximation based on sampling.

Application

An important application of this method is the intergral calculation.
For z1,z2,...,zNp(z|x), where p(z|x) is a posterior distribution with latent variable z and observed data x, one can calculate the expectation of the posterior via sampling:

Ez|x[f(z)]=p(z|x)f(z)dz1Ni=1Nf(zi)

Then a question comes along: How to know the posterior? How to sample from the posterior?

Sampling Methods

There are several sampling methods.

Sampling via CDF

Ideally, if one samples uU(0,1) and locates it on Y-axis of a CDF, a corresponding inverse CDF can be acquired.
This method only works for very simple PDF/CDF forms, e.g. normal distributions.

Rejection sampling

Rejection sampling means that for the probability of z(i), if it falls in the area under p(z), we accept it; if it falls outside the area of p(z) and inside the area of Mq(z) (where q(z) is a proposal distribution, and Mq(zi) is always larger than p(zi)), we reject it, i.e. :

zi,Mq(zi)p(zi)

then we define α as the ratio of acceptance, i.e.

α=p(zi)Mq(zi)  (0α1)

Rejection sampling steps:

  1. sample ziq(z)
  2. sample uU(0,1)
  3. decision:
    • if uα, accept zi;
    • else, reject zi

Importance sampling

Importance sampling samples from the expectations Ez|x[f(z)].

Ez|x[f(z)]=p(z|x)f(z)dz=f(z)p(z)q(z)q(z)dz1Ni=1Nf(zi)p(zi)q(zi)

where the p(zi)q(zi) is the weight, and again q(z) is a proposal distribution.