VARIATE GENERATION USING THE INVERSE TRANSFORM METHOD

4.2 VARIATE GENERATION USING THE INVERSE TRANSFORM METHOD

The single-variate generation problem seeks to transform an iid uniform sequence of variates fU n g into an iid sequence of variates fX n

g, such that X n desirable that the generation method be general, namely, applicable to any requisite distribution, G.

The most general and widely used method is the Inverse Transform method [see Law and Kelton (2000), and Banks et al. (1999)]. It relies on the following properties of the cdf F X (x) of a variate X, and their relation to a uniform variate U Evaluating the distribution function F X (x) at the underlying variate X results in a variate U, given by

(4 :2) whose cdf is uniform between 0 and 1.

U ¼F X (X ),

Conversely, evaluating an inverse distribution function F 1 X (u) at a uniform variate U

X ¼F 1 X (U )

(4 :3) with cdf F X (x). Note that since every cdf, F X (x), is nondecreasing (from 0 to 1), it

follows that its inverse, F 1 X (u), is always well defined. For a given cdf F X (x), Eq. 4.3 implicitly describes the generation of the underlying variate, X, via the Inverse Transform method as a two-step algorithm:

1. Use your favorite RNG to generate a realization u from a variate U

2. Compute x ¼F 1 X (u) as a realization of X.

Figure 4.1 illustrates graphically an application of the Inverse Transform method.

x)

0 x x=F X −1 (u)

Figure 4.1 The Inverse Transform method.

58 Random Number and Variate Generation We now proceed to demonstrate the use of the Inverse Transform method through

several examples. We mention that Arena/SIMAN supports variate generation from selected distributions (see Section 7.4). We also point out that Arena samples values in an intelligent way. For example, when sampling in the context of interarrival or service times (which cannot be negative), Arena will discard any sampled negative values and will continue sampling until a non-negative value is obtained (see Kelton et al. 1998). Note, however, that this procedure can change the underlying distribution to

a conditional one (in this case the conditioning is on non-negative values).

4.2.1 G ENERATION OF U NIFORM V ARIATES

Suppose we wish to generate a realization x from the uniform distribution Unif (2, 10), for a realization u ¼ 0:65 of the underlying RNG. Recalling the uniform cdf, given by Eq. (3.51), we write it as

where u is given and x is unknown. Solving the above for x to obtain the inverse cdf readily yields the formula

(4 :4) and substituting a ¼ 2, b ¼ 10, and u ¼ 0:65 into the above results in the requisite

4.2.2 G ENERATION OF E XPONENTIAL V ARIATES

Suppose we wish to generate a realization x from the exponential distribution Expo (0.5) with rate l ¼ 0:5 (mean 2), for a realization u ¼ 0:45 of the underlying RNG. Recalling the cdf of the exponential distribution, given by Eq. 3.62, we write it as

u ¼1 e lx

where u is given and x is unknown. Solving the above for x readily yields the formula

and substituting l ¼ 0:5 and u ¼ 0:45 into the above results in the requisite value

2 ln (1 0 :45) ¼ 1:1957:

We mention that for practical simulation, Eq. 4.5 may be simplified into the equivalent formula

x ¼F X (u) ¼

ln (u),

because if U

Random Number and Variate Generation 59

4.2.3 G ENERATION OF D ISCRETE V ARIATES

Suppose we wish to generate a realization x from a discrete distribution, whose pmf, p X (x), is specified in Table 4.2, for a realization u ¼ 0:45 of the underlying RNG.

Suppose we code the state space by integers, say, S ¼ f1, 2, . . .g as in our example. Recalling the discrete cdf, given by Eq. 3.36, we rewrite it as

where k is the unique integer satisfying the equation above. Next, utilizing the general formula for an inverse cdf from Eq. 3.12, we deduce that the inverse cdf can be written as

X k x ¼F X (u) ¼

k1

k1 F k (u), where F k ¼

or equivalently,

X k1

x ¼F 1 X (u), for

In our case, (4.7) becomes

and the corresponding graph is shown in Figure 4.2.

Table 4.2 Specification for a pmf for a discrete variate

x) F X ( 0.45

x Figure 4.2 The Inverse Transform method for generating a discrete variate.

60 Random Number and Variate Generation It follows that the requisite variate realization corresponding to u ¼ 0:45 is

x ¼F 1

X (0 :45) ¼ 4, since k ¼ 2 for this value of u.

4.2.4 G ENERATION OF S TEP V ARIATES FROM H ISTOGRAMS

Suppose we wish to generate a realization x from a step distribution with J ¼ 4 steps, whose pdf is specified in Table 4.3, for a realization u ¼ 0:5 of the underlying RNG. Recalling the step cdf, given by Eq. 3.55, we write it as

if x J . Solving (4.8) for x yields the inverse step cdf,

The graph corresponding to Eq. 4.9 for this example is shown in Figure 4.3.

Table 4.3 Specification for a step pdf for a continuous variate

Figure 4.3 The Inverse Transform method for generating a variate with a step pdf.

Random Number and Variate Generation 61 It follows that the requisite variate realization corresponding to u ¼ 0:5 is