Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose we now have a Erlang distribution $b(x;2,1) = x e^{-x}$. According to the definition of Erlang distribution we know that the variance of such a distribution is 2 and we want to reduce the variance of this model. So we hope that the modified time $\tilde{b}$ would fall faster than the original $b$. We're trying to use:

$\tilde{b} = \begin{cases} \frac{1}{c} x e^{-x} & 0 < x < t \\ \frac{1}{c} t e^{-x} & x \geq t\end{cases}$.

Integration tells us $c = 1 - e^{-t}$. And after we choose $c$, how should we generate such a random variable?

share|cite|improve this question
In this case, finding the inverse of the cdf is problematic, so I would look for ideas under rejection sampling. – André Nicolas Mar 1 '12 at 1:12
@AndréNicolas Thanks Andre. Can you amplify your ideas a bit? – Mathematics Lover Mar 1 '12 at 1:14
Not really, there are many "tricks of the trade," so specific suggestions I make would likely be inefficient. You can start with this link. It will provide you with the basics. Essentially you produce a pleasant larger region than the one you want, produce a random number uniformly distributed over the larger region, test whether it lies in your desired region (easy), keep if it does, try again if it doesn't. The trick is not to waste too high a proportion of your random number production. – André Nicolas Mar 1 '12 at 1:25
up vote 1 down vote accepted

In order to have an answer, here is something that will work. It is based on the idea of Rejection Sampling. Call your modified density function $f(x)$.

Use a pseudo-random number generator that simulates the values of a random variable uniformly distributed on $(0,1)$. Suppose that this generator produces the numbers $u$ and $v$.

Let $x=-\ln u$. If $$f(x) \ge vte^{-x},$$ accept $x$ as coming from sampling from our distribution. Else reject $x$. Repeat. This is a close relative of the usual Monte Carlo method for finding the area of a complicated figure.

This procedure unfortunately could have a high rejection rate, making it time-consuming to generate a large pseudo-random sample. So modifications may need to be made if we are to have a practical method.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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