How should I generate this random variable? 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?

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. 
