How to generate random numbers with Laplace distribution using uniform distribution

3.3k Views Asked by At

I want to prove that transfrom $x=\ln\frac{y_1}{y_2}$ generate random numbers with Laplace distribution where $y_1$ and $y_2$ are unifom random numbers $U \sim (0,1)$.

And also transform $x=y_1-y_2$ generate random numbers with Laplace distribution where $y_1$ and $y_2$ are random numbers with exponential distribution $y_1,y_2\sim \mathrm{Exp}(1/\lambda)$

So I tried to do this with transform method but I didn't succeeded to do anything

Is someone has idea how to do this?

2

There are 2 best solutions below

4
On BEST ANSWER

Suppose $w\le 0$. Then $$ \Pr(\ln y_1 \le w) = \Pr(y_1 \le e^w) = e^w. \tag 1 $$ That gives you the distribution of $\ln y_1$ on the interval $(-\infty,0]$. The derivative of $(1)$ with respect to $w$ is the density function on that interval, so that is $w\mapsto e^w$.

The density of the pair $(\ln y_1,\ln y_2)$ on the third quadrant $(-\infty,0]^2$ is therefore $(w_1,w_2) \mapsto e^{w_1} e^{w_2} = e^{w_1+w_2} \vphantom{\frac 1 1}$, and the probability measure in that quadrant is thus $e^{w_1+w_2}\,dw_1\,dw_2$.

Let us seek the cumulative distribution function of the difference $\ln y_1 - \ln y_2 = \ln \dfrac{y_1}{y_2}$. Since the distribution of $\ln y_1 - \ln y_2 = \ln \dfrac{y_1}{y_2}$ is the same as that of $\ln y_2 - \ln y_1 = \ln \dfrac{y_2}{y_1}$, we only need to do this in the case where $\ln y_1 - \ln y_2 = \ln \dfrac{y_1}{y_2}<0$. Suppose $u<0$ and we seek $\Pr(\ln y_1 - \ln y_2 \le u)$. We are in the region of the third quadrant where where $w_1 - w_2 \le u$.

So

  • $w_2\le 0$, and
  • For each fixed value of $w_2$ we have $w_1 \le w_2+u$.

Thus the probability is $$ \int_{-\infty}^0 \left( \int_{-\infty}^{w_2+u} e^{w_1+w_2} \, dw_1 \right) \, dw_2 = \int_{-\infty}^0 e^{2w_2+u} \,dw_2 = e^u \int_{-\infty}^0 e^{2w_2}\, dw_2 = \frac 1 2 e^u. $$ This is the cumulative distribution function on $(-\infty,0]$. Then density is its derivative, and it is its own derivative. By symmetry, therefore, the density on the whole real line is $$ u \mapsto \left.\begin{cases} \frac 1 2 e^u & \text{if }u<0, \\[6pt] \frac 1 2 e^{-u} & \text{if }u>0, \end{cases} \right\} = \frac 1 2 e^{-|u|}. $$

2
On

If $X = \log \frac{Y_1}{Y_2}$ where $Y_1,Y_2 \sim$ i.i.d. Uniform(0,1) then $P(X \leq x) = P(\log \frac{Y_1}{Y_2} \leq x) = P(\frac{Y_1}{Y_2} \leq e^x) = \int_{\frac{y_1}{y_2} \leq e^x, 0\leq y_1 \leq 1, 0 \leq y_2 \leq 1} dy_1 dy_2 = \frac{1}{2} e^{-|x|}$.

Alternatively, use moment generating functions: $E[e^{t X}] = E[e^{t \log \frac{Y_1}{Y_2}}] = E[(\frac{Y_1}{Y_2})^t] = E[Y_1^t]E[Y_2^{-t}]$. You can calculate the expectation $E[Y_1^t]= \int_0^1 y^t (1) dy$ and similarly $E[Y_2^{-t}] = \int_0^1 y^{-t} (1) dy$ and match $E[e^{tX}]$ with the MGF of a laplace random variable. Or you can do the same thing with characteristic functions.

The second one is easy by moment generating functions (or characteristic functions): $E[e^{t (Y_1 - Y_2)}] = E[e^{t Y_1}] E[e^{-t Y_2}] = M(t) M(-t)$ where $M(t)$ is the moment generating function of an Exp$(1/\lambda)$ random variable. Match $M(t) M(-t)$ to the moment generating function of a Laplace distribution.