2
$\begingroup$

The p.d.f. of the random variable $X$ is given by $f(x) = \begin{cases} e^{x-2} & \mbox{for $0 \leq x \leq 2$}, \\ e^{-x} & \mbox{for $x > 2$}, \\ 0 & \mbox{otherwise,} \end{cases}$

I need to find $F^{-1}(y)$ to construct a generator for $X$. So I start with calculating the cdf by taking the integral of $f(x)$: $$ F(X)= \begin{cases} \frac{e^x-1}{e^2} & 0 \leq x \leq 2 \\ -e^{-x}+e^{-2} & x \geq 2 \\ 0 & o.w \end{cases} $$ Next, I need to find the inverse of this function: $$y = \frac{e^x-1}{e^2} \implies x= \ln(e^2y+1) \text{ for } y \in [0, 1-e^{-2}]$$

$$y=-e^{-x}+e^{-2} \implies x = -\ln(e^{-2}-y) \text{ for }y \in (0, e^{-2})$$

Now at this point I am confused since the intervals for $F^{-1}(y)$ overlap. How do I break this up into cases? Did I screw up a calculation along the way( I retraced my steps and it seems fine...)?

$\endgroup$
7
  • 1
    $\begingroup$ One way to simplify your work is to express $X$ as a mixture of two variables (one is supported on $[0,2]$ and the other on $(2,\infty).$) This splits the problem into one part concerned within finding the CDF of a mixture (which is easy), finding its inverse (also easy), and inverting the individual CDFs of the mixture components (elementary and easy in this example). $\endgroup$
    – whuber
    Sep 27, 2020 at 15:03
  • $\begingroup$ I am not quite sure what you mean when you say "express as a mixture of two variables". If I may request, could you put those terms into an example with math symbols? $\endgroup$
    – hkj447
    Sep 27, 2020 at 15:07
  • 1
    $\begingroup$ A mixture distribution $F$ is of the form $F(x)=\sum_{i=1}^n \omega_i F_i(x)$ where each of the $F_i$ is a distribution function, implying the $\omega_i$ sum to unity (and usually people take all $\omega_i$ to be positive). One way random variables with mixture distributions arise is through a two-stage process: Let $U$ be a discrete distribution with $\Pr(U=i)=\omega_i$ and let the distribution of $X$ conditional on $U=i$ be given by $F_i.$ The only calculations you need to do are to figure out the $\omega_i.$ $\endgroup$
    – whuber
    Sep 27, 2020 at 15:12
  • $\begingroup$ A search shows we have a great deal of information about this. $\endgroup$
    – whuber
    Sep 27, 2020 at 15:21
  • 1
    $\begingroup$ BTW, your expression for $F$ is incorrect: notice it resets to $0$ as $x$ crosses from less than $2$ to greater than $2,$ yet it's impossible for any valid distribution function to decrease at all. It can be helpful to graph $f$ and use that graph to sketch what $F$ must look like: that tends to prevent such mistakes. $\endgroup$
    – whuber
    Sep 27, 2020 at 20:02

1 Answer 1

1
$\begingroup$

As @whuber comments, your CDF is not correct. My plot of your CDF (from R) is shown below. It is OK for a PDF to be discontinuous, but the CDF of a continuous random variable must be continuous. First, you might try differentiating your CDF (piecewise) to see whether the result is your PDF.

enter image description here

 curve((exp(x)-1)/exp(x), 0,2, xlim=c(0,10), ylim=0:1,ylab="CDF")
  curve(-exp(-x) + exp(-2), 2,10, add=T)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.