Sampling from a sum of two distributions

216 Views Asked by At

Suppose I have two cumulative probability density functions $F$ and $G$. It is well known that I can sample from $F$ using $F^{-1}(X)$, where $X$ is uniformly distributed.

Now let $H = hF + (1-h)G$ for some $h \in [0, 1]$. Intuitively, I feel that I should be able to sample from $H$ using the following function:

$$ U^{-1}(X) = \begin{cases} F^{-1}(X/h), & X < h, \\ G^{-1}((X-h)/(1-h)), & X > h. \end{cases} $$

In effect, we use the uniform random variable first to choose between $F$ and $G$, and then to sample from it. Is my thinking correct, or are there some caveats?

1

There are 1 best solutions below

2
On BEST ANSWER

Your approach is correct! Here is the proof (I assume $h\in (0,1)$):

Let $U\sim Unif[0,1]$ and sample according to

$$ Y = \begin{cases} F^{-1}\left(U\over h\right), & U \leq h, \\ G^{-1}\left({U-h\over 1-h }\right), & U > h \end{cases}. $$ Then

$$\begin{align}P(Y\leq y)&=P(Y\leq y,U\leq h)+P(Y\leq y,U> h)\\ &=P\left(F^{-1}\left(U\over h\right)\leq y,U\leq h\right)+P\left(G^{-1}\left({U-h\over 1-h }\right)\leq y,U>h\right)\\ &=P\left(U\leq hF(y),U\leq h\right)+P\left(U\leq h+(1-h)G(y),U>h\right)\\ &=P\left(U\leq \min\{hF(y),h\}\right)+P\left(h<U\leq h+(1-h)G(y)\right)\\ &=P\left(U\leq hF(y)\right)+P\left(h<U\leq h+(1-h)G(y)\right)\\ &=hF(y)+(1-h)G(y) \end{align}$$

as desired.


Here is an alternative approach: Let $U_1,U_2\sim Unif[0,1]$ be independent and sample according to

$$ Y = \begin{cases} F^{-1}(U_2), & U_1 \leq h, \\ G^{-1}(U_2), & U_1 > h \end{cases}. $$

Then

$$\begin{align}P(Y\leq y)&=P(U_1\leq h)P(Y\leq y|U_1\leq h)+P(U_1> h)P(Y\leq y|U_1> h)\\ &=hP(F^{-1}(U_2)\leq y)+(1-h)P(G^{-1}(U_2)\leq y)\\ &=hP(U_2\leq F(y))+(1-h)P(U_2\leq G(y))\\ &=hF(y)+(1-h)G(y)\\ \end{align}$$

as desired.