Inverse Transformation Sampling
Sample from D with density f(x) and CDF F(x), given U∼Unif(0,1). Find T such that T(U)=X∼D.
P(X≤x)=P(T(U)≤x)=P(U≤T−1(x))=T−1(x)
So F(x)=T−1(x), i.e. T=F−1. Sample from U and plug into F−1: the result is a sample from D. If F is not invertible, use the generalized inverse F←(u)=inf{x:F(x)≥u} (see random variables).
Rejection Sampling
Sample from P with density f(x)/Z. Choose a proposal G with density g(x) such that
- the support of G contains the support of P,
- G is possible to sample,
and choose M such that f(x)≤Mg(x) for all x.
Algorithm Sample s from G, and accept s with probability Mg(s)f(s).
P(s∣Accept)=P(Accept)P(Accept∣s)P(s)=∫g(s)Mg(s)f(s)dsMg(s)f(s)g(s)=M1∫f(s)dsf(s)/M=Zf(s)=density of P