If you do numerical simulations you often find yourself needing to generate random variates from a specific distribution. There are several techniques for doing this, such as the inverse transform method and the acceptance-and-rejection method. This post will talk about a simple way to generate variates from the geometric and truncated exponential distributions, where the latter is the exponential distribution restricted to the range .

The classic example of the inverse transform method is generating random variates from an exponential distribution. (This is because the exponential cdf is so easy to invert.) If uniform, and , then exponential. So it’s easy to generate exponential random variates.

Then, to get geometric and truncated exponential random variates, all you have to do is take and , the integer and fractional parts of , respectively! More explicitly, the integer part has a geometric distribution, and the fractional part has the truncated exponential distribution on .

*Proof:*

If we fix and substitute 1 for we have .

Thus geometric.

If we fix and sum over all possible values of we have

Now, is the cdf of an exponential distribution, and is the probability that an exponential random variable is no greater than 1. Thus has this truncated exponential distribution — an exponential distribution whose values are not allowed to be greater than 1.

See, for example, Eisenberg [1] or my answer to “Random exponential-like distribution” on math.SE.

**References**

1. Bennett Eisenberg, “On the expectation of the maximum of IID geometric random variables,” *Statistics and Probability Letters* 78 (2008) 135-143.

### Like this:

Like Loading...

*Related*