How should I sample from a mixture distribution?
The mixture distribution can be obtained in the following way.
Let $f(x)=w_1p_1(x) + w_2p_2(x) + ... + w_np_n(x)$, where $p_i$ are density functions and $w_i&gt;0$. Note that $f(x)$ is a density function if the sum of all weights is one.
Then, we use the following two-stage process.
Stage 1. Draw a random variable $X$ (selector, if I remember correctly), such that $P(X=i)=w_i$ for $i=1,2,...,n$.
Stage 2. Return a random variable drawn accordingly to $p_X$, where $X$ is the index obtained in the stage 1.