How to generate random numbers with Laplace distribution using uniform distribution

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?

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|}.$$

• This is what I call an answer...it's great...please could you show me how to do this with second one x=y1-y2 – xyz Dec 25 '15 at 21:26
• @xyz : This includes the second one. If $y_1,y_2$ are independent random variables that are uniformly distributed on $[0,1]$, the $-\ln y_1$ and $-\ln y_2$ are independent random variables that are exponentially distributed with c.d.f. $F(x) = \begin{cases} 1-e^{-x} & \text{if }x\ge 0, \\ 0 & \text{if }x<0. \end{cases}$ ${}\qquad{}$ – Michael Hardy Dec 25 '15 at 23:18
• Actually$y_{1}$ and $y_{2}$ are not uniformly distributed, they have exponential distribution and $x$need to be also with Laplace distribution.. @Michael Hardy – xyz Dec 25 '15 at 23:49
• @xyz : In your first question, $y_1$ and $y_2$ were uniformly distributed and $-\ln y_1$ and $-\ln y_2$ were exponentially distributed. You asked about the distribution of $\ln(y_1/y_2)$, and that his the distribution of $\ln y_1 - \ln y_2 = (-\ln y_2) - (-\ln y_1)$, thus the distribution of the difference between two exponentially distributed random variables. That turned out to be a Laplace distribution. In your second question, you supposed that $y_1$ and $y_2$ are exponentially distributed. The distribution of their difference is still a Laplace distribution. ${}\qquad{}$ – Michael Hardy Dec 26 '15 at 0:31

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.

• I would like to ask you if you could show me how to do this second one with characteristic function....this moment generating functions are little bit confusing... and thank you so much...you really helped me – xyz Dec 25 '15 at 20:57
• Replace $t$ with $i \omega$, and the calculation is the same. – Batman Dec 25 '15 at 20:58