Applying the inverse transformation method or acceptance-rejection method

898 Views Asked by At

Give a method for generating a random variable with density function $$f(x) = \begin{cases} e^{2x}, - \infty < x < 0\\ e^{-2x}, 0 < x < \infty \end{cases}$$

Thoughts: I was thinking of either using the inverse transformation method or the acceptance-rejection method but I am thrown off by how to apply either of those methods for this specific density function, any thoughts or suggestions are greatly appreciated

We could apply the inverse transformation method where we have two cases:

Case 1: $f(x) = e^{2x}$, $-\infty < x < 0$. Solve $U_1 = f(x)$ for $x$ where $U_1\sim U(0,1)$.

Case 2: $f(x) = e^{-2x}$, $0 < x < \infty$. Solve $U_2 = f(x)$ for $x$ where $U_2\sim U(0,1)$.

1

There are 1 best solutions below

6
On BEST ANSWER

The distribution is a two-sided exponential. The PDF could also be written $f(x) =e^{-2|x|}.$ So it's symmetric.

You could first generate an exponential with mean $1/2$ using inverse CDF. This is done by just taking $U\sim U[0,1]$ and then $Z=-\ln(U)/2.$ Then you could draw another $U_2\sim U[0,1]$ to determine the sign. Take $X=Z$ if $U_2<1/2$ and $X= -Z$ otherwise.

You could also do it more directly with an inverse transform. Here the trick is computing the CDF and its inverse. By taking $$ F_X(x) = \int_{-\infty}^x f(t)dt$$ you can see that $$ F_X(x) = \left\{\begin{array}{ll} \frac{1}{2}e^{2x}& x<0 \\1-\frac{1}{2}e^{-2x} & x \ge0\end{array}\right.$$ Then the inverse is $$ F^{-1}_X(y) = \left\{\begin{array}{ll} \frac{1}{2}\ln(2y)& 0<y<1/2 \\-\frac{1}{2}\ln(2(1-y)) & 1/2\le y\le 1\end{array}\right.$$

So you could also draw a single uniform $U\sim U[0,1]$ and take $X=F^{-1}(U).$