Classifications of Random Variates Generation Algorithms

6.1.1 CDF-inverse method

Let a random variable X have the cumulative distribution function (CDF) Fx(x). From Sec. 2.3.1, Fx(x) is a nondecreasing function with respect to the value of x, and 0 < Fx(x) < 1. Therefore, F-1(u) may be defined for any value of u between 0 and 1 as F-1(u) is the smallest x satisfying Fx(x) > u.

For the majority of continuous probability distributions applied in hydrosys­tems engineering and analysis, Fx(x) is a strictly increasing function of x. Hence a unique relationship exists between Fx (x) and u; that is, u = Fx (x), as shown in Fig. 6.1. Furthermore, it can be shown that if U is a standard uniform ran­dom variable defined over the unit interval [0, 1], denoted by U ~ U(0,1), the following relationship holds:

X = Fx-1(U) (6.6)

Note that X is a random variable because it is a function of the random variable U. From Eq. (6.6), the one-to-one correspondence between X and U, through the CDF, enables the generation of random numbers X ~ Fx(x) from the standard uniform random numbers. The algorithm using the CDF-inverse method for generating continuous random numbers from a CDF Fx(x) can be stated as follows:

1. Generate n uniform random numbers u1, u2,…, un from U(0,1).

2. Solve for xi = F-1(ui), for і = 1, 2,…, n.

Fx(x) = u

Classifications of Random Variates Generation Algorithms

Figure 6.1 Schematic diagram ofthe inverse-CDF method for generating random variates.

Example 6.1 Consider that the Manning roughness coefficient X of a cast iron pipe is uncertain, having a uniform distribution fx(x) = 1/(6 — a), a < x < b. Develop an algorithm using the CDF-inverse method to generate a random Manning roughness coefficient.

Classifications of Random Variates Generation Algorithms
Подпись: A simple algorithm for generating uniform random variates from U(a, b) is 1. Generate n standard uniform random variates ui, u2,..., un from U(0,1). 2. Calculate the corresponding uniform random variates xi = a + (b — a)ui, i = 1, 2,..., n.
Подпись: In the case that the random variables under consideration are discrete, the value of xj corresponding to the generated standard uniform random variate u must satisfy j—1 j Fx(xj—1) = ^ fx(xi) < u < Fx(xj) = Y, fx(xi) (6.7) i=1 i=1 The CDF-inverse algorithm for generating discrete random variates can be implemented as follows: 1. Generate the uniform random number u from U(0, 1). 2. Initialize i = 0 and set p = 0. 3. Let i = i + 1, and compute p = p + fx(xi). 4. If p < u, go to step 3; otherwise, stop, and xi is the random variate sought. Example 6.2 Suppose that the number of snow storms X at a location in January has a discrete uniform distribution fx(x) = 1/5 for x = 0,1, 2, 3, 4 Develop an algorithm to generate a sequence of random number of snow storms. Solution The CDF for the number of snow storms can be written as Fx(x) = (x + 1)/5 for x = 0,1, 2, 3, 4 The algorithm for this example can be outlined as follows. 1. Generate the uniform random number u from U(0, 1). 2. Initialize x = 0 and p1 = 0, and compute Fx(0).

Solution Using the CDF-inverse method, the expression of the CDF of the random variable is first sought. The CDF for this example can be derived as

3. Test if pi < u < Fx(x). If yes, x is the solution; otherwise, go to step 4.

4. Let p1 = Fx(x), x = x + 1, and compute Fx(x + 1). Go to step 3.

To apply the CDF-inverse method for generating random numbers efficiently, an explicit expression between X and U is essential so that X can be obtained analytically from the generated U. The distributions the inverse forms of which are analytically expressible include exponential, uniform, Weibull, and Gumbel. Table 6.3 lists some distributions that are used in hydrosystems the CDF in­verses of which are analytically expressible.

When the analytical forms of the CDF inverse are not available, applying the CDF-inverse method would require solving

/

x

fx (t) dt (6.8)

-TO

for x from the known u. For many commonly used distributions such as normal, lognormal, and gamma, solving Eq. (6.8) is inefficient and difficult. More effi­cient algorithms have been developed to generate random variates from those distributions; some of these are described in Sec. 6.4.

Updated: 19 ноября, 2015 — 9:14 пп