I came up with the following question when I read a paper in Economics:

Let $Z:\Omega\to\Bbb{R}$ be a random variable with density $$ f(z)=\begin{cases} \frac{1}{\sigma}\exp\left({-\frac{z+\mu}{\sigma}}\right),&\quad z+\mu\geq 0\\ 0,&\quad\text{ otherwise}. \end{cases} $$ where $\mu$ and $\sigma$ are constants. Give $\theta\in(0,1)$, define a random variable $R:\Omega\to\Bbb{R}$ such that $$ P(R=0)=\theta,\quad P(R=Z)=1-\theta. $$

Here are my questions:

  • [Added:] How can I generate a numerical sample of $R$, using the inverse transform sampling?
  • Is there any other way than the [inverse transform sampling] to generate a sample?
  • 2
    $\begingroup$ $R$ is a mixed random variable that has a continuous distribution on $(-\mu, \infty)$ and an atom at $0$. Thus, the CDF has a jump discontinuity at $0$ that you would need to take into account in getting a sample of $R$ from R. $\endgroup$ Nov 5, 2015 at 2:22
  • 2
    $\begingroup$ @Dilip Alternatively, you can represent $R=ZU$ where $U$ is an independent Bernoulli variable with probability $1-\theta$ of being $1$ and probability $\theta$ of being $0$. $\endgroup$
    – whuber
    Nov 5, 2015 at 5:09
  • 1
    $\begingroup$ @whuber If I had to devise a method, then (taking $\mu=0$ and $\sigma=1$ for simplicity) I would do something like Generate $Z \sim U(0,1)$. if $(1-\theta) < Z < 1$, return $0$, else return $-\ln \frac{Z}{1-\theta}$ which requires only one call to a random number generator. For other values of $\mu$ and $\sigma$, all that is needed is to modify the $-\ln \frac{Z}{1-\theta}$ appropriately. Of course, this does use inverse transform sampling and so is not an answer to the_question_ asked here: "Is there any other way than inverse transform sampling?" $\endgroup$ Nov 5, 2015 at 15:59
  • 1
    $\begingroup$ @Dilip Very good! If you want to avoid inverse transform sampling, then you might recognize an exponential distribution as a (recentered, rescaled) $\chi^2_2$ distribution, which is easily sampled by summing the squares of two independent standard Normal variates. As you know, there are many ways to generate those without inverse transformations. Or, you could interpret the question specifically as wishing to avoid use of the inverse transform of $R$, which you have already accomplished. $\endgroup$
    – whuber
    Nov 5, 2015 at 16:34
  • $\begingroup$ @DilipSarwate and whuber, thank you very much for your comment. I edited my question accordingly so that one can see the useful comments as an answer. $\endgroup$
    – user57337
    Nov 5, 2015 at 16:40

1 Answer 1


Discussion in comments above converted into an answer.

You can generate a sample of $R$ using the following method which uses inverse transform sampling but not the inverse transform of $R$ which has a mixed distribution that would need some extra steps in handling via direct inverse transform sampling.

Notice that $Z$ is an exponential random variable with mean $\sigma$ that has been displaced to the left by $\mu$, that is, $\displaystyle \frac{Z+\mu}{\sigma}$ is an exponential random variable with mean $1$. So, we can use the following method to generate a sample of $R$.

  • Generate $Y \sim U(0,1)$.

  • If $1-\theta < Y < 1$, set $R = 0$, else set $\displaystyle R = -\sigma \ln\left(\frac{Y}{1-\theta}\right) - \mu$.

If $Y$ is known to have value in $(0, 1-\theta)$, the conditional distribution of $\frac{Y}{1-\theta}$ is uniform on $(0,1)$ and so $-\ln \left(\frac{Y}{1-\theta}\right)$ is an exponential random variable with mean $1$. This is readily converted to an exponential random variable with mean $\sigma$ and then displaced by $\mu$ to the left.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.