0
$\begingroup$

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 Answers 1

1

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

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

  • 0
    could you provide a little more details. I will edit what I was just thinking now2017-02-24
  • 0
    See edited question, is the approach I have there incorrect? If so, could you provide a more detailed solution so I understand?2017-02-24
  • 0
    @Wolfy I can't tell what the procedure is in your solution. Also, you need to invert the CDF not the PDF (but for various reasons it words out to be the same in the case of a one-sided exponential).2017-02-24
  • 0
    I thought I was using the inverse transformation method, I just did the same thing that my notes did for applying the inverse transformation to a poisson density or an exponential density, they use the PDF in those cases.2017-02-24
  • 0
    That being said I think I understand you solution, is it complete or should I include an algorithm (pseudo-code)?2017-02-24
  • 0
    @Wolfy It's complete as I see it but it might be best organized as pseudocode. The problem with pure inverse transform for this is computing the inverse of the CDF, which is piecewise. It is pretty straightforward here so I included it.2017-02-24