APPENDIX B ELEMENTS OF MONTE CARLO SIMULATION B. GENERAL CONCEPT The basic idea of Monte Carlo simulation is to create a series of experimental samples using a random number sequence. According to the Central Limit Theorem or the Law of Large Numbers, the sample mean can be used as an unbiased estimate of the mathematical expectation when the number of samples is large enough. The variance of the sample mean is an indicator of estimation accuracy. Take the application of Monte Carlo simulation to risk assessment as an example. Let U denote the unavailability or failure probability of a system and x i be the zero one indicator variable that can be obtained using a Monte Carlo simulation method: x i = if the sampled system state is a failed one x i = 0 if the sampled system state is a successful one The estimate of the system unavailability is given by the following sample mean: U = N x N i i= (B.) where N is the number of system state samples. The sample variance is defined as V(x) = N (x i U) 2 (B.2) N i= Risk Assessment of Power Systems. By Wenyuan Li 289 ISBN 0-47-6368-X 2005 the Institute of Electrical and Electronics Engineers, Inc.
290 ELEMENTS OF MONTE CARLO SIMULATION The estimated unavailability given in Equation (B.) is also a random variable that depends on the number of samples and the sampling process. The uncertainty around the estimate can be measured by the variance of the sample mean, which is defined as V(x) V(U) = = N (x i U) 2 (B.3) N N(N ) It can be seen that the sample variance V(x) given by Equation (B.2) and the variance of the sample mean V(U) given by Equation (B.3) are two different concepts and should not be confused with each other. The standard deviation of the sample mean is i= V (x ) = V (U ) = (B.4) N Equation (B.4) indicates that two measures can be used to reduce the standard deviation of the estimate in Monte Carlo simulation: increasing the number of samples or decreasing the sample variance. Many variance reduction techniques have been developed to improve the effectiveness of Monte Carlo simulation. It is important to appreciate that the variance cannot be reduced to zero in any case and, therefore, it is always necessary to consider a reasonable and sufficiently large number of samples. Monte Carlo simulation creates a fluctuating convergence process and there is no guarantee that a few more samples will definitely lead to a smaller error. It is true, however, that the error bound or confidence range decreases as the number of samples increases. The accuracy level of Monte Carlo simulation can be measured using the coefficient of variance, which is defined as the standard deviation of the estimate divided by the estimate: = V (U ) /U (B.5) The coefficient of variance is often used as a convergence criterion. B.2 RANDOM NUMBER GENERATORS Generating a random number is a key step in Monte Carlo simulation. Theoretically, a random number generated by a mathematical method is not really random and is called a pseudorandom number. In principle, a pseudorandom number sequence should be statistically tested to assure its randomness. B.2. Multiplicative Congruent Generator The multiplicative congruent generator is given by the following recursive relationship:
B.2 RANDOM NUMBER GENERATORS 29 x i+ = ax i (mod m) (B.6) where a is the multiplier and m is the modulus; a and m have to be nonnegative integers. The module notation (mod m) means that x i+ = ax i mk i (B.7) where k i = [ax i /m] denotes the largest positive integer in ax i /m. Given an initial value x 0 that is called a seed, Equation (B.6) generates a random number sequence which lies between [0, m]. A random number sequence uniformed distributed in the interval [0, ] can be obtained by R i = x i m (B.8) Obviously, the random number sequence generated using Equation (B.6) will repeat itself in at most m step and is periodic. If the repeat period equals m, it is called a full period. Different choices of the parameters a and m produce large impacts on the statistical features of random numbers. Based on many statistical tests, the following parameters provide satisfactory statistical features in generated random numbers: m = 2 3 a = 6807 or 63036006 The initial value x 0 is any odd number. B.2.2 Mixed Congruent Generator The mixed congruent generator is given by the following recursive relationship: x i + = (ax i + c)(mod m) (B.9) Compared to the multiplicative congruent generator, the new parameter c is added in the mixed congruent generator. The quantity c is called the increment and it also has to be a nonnegative integer. Statistical tests indicate that the following two sets of parameters provide satisfactory statistical features in generated random numbers: m = 2 3 m = 2 35 a = 3459269 a = 5 5 c = 453806245 c =
292 ELEMENTS OF MONTE CARLO SIMULATION B.3 INVERSE TRANSFORM METHOD OF GENERATING RANDOM VARIATES A random variate refers to a random number sequence following a given distribution. The two random number generators presented in Section B.2 generate the random number sequence following a uniform distribution between [0, ]. The methods for generating the random variates following other distributions can be classified into three categories: () inverse transform method, (2) composition method, and (3) acceptance rejection method. This section only covers the inverse transform method, which is most commonly used. The inverse transform method is based on the following proposition: If a random variate R follows a uniform distribution in the interval between [0, ], the random variate X = F (R) has a continuous cumulative probability distribution function F(x). The proposition can be generalized to the case of a discrete distribution, and in this case the inverse function is defined as X = F (R) = min{x : F(x) R} (0 R ) (B.0) The procedure of generating random variates using the inverse transform method is as follows: Generate a uniformly distributed random number sequence R between [0, ] Calculate the random variate which has the cumulative probability distribution function F(x) by X = F (R) For some random variates, the cumulative probability distribution function does not have the explicit expression of its inverse function. In this case, an approximate analytical expression is needed. B.4 IMPORTANT RANDOM VARIATES IN RISK EVALUATION B.4. Exponential Distribution Random Variate The cumulative probability distribution function of the exponential distribution is F(x) = e x (B.) A uniform distribution random number R is generated so that R = F(x) = e x (B.2)
B.4 IMPORTANT RANDOM VARIATES IN RISK EVALUATION 293 Using the inverse transform method, we have X = F (R) = ln( R) (B.3) Since ( R) distributes uniformly in the same way as R in the interval [0, ], Equation (B.3) equivalently becomes X = ln(r) (B.4) where R is a uniform distribution random number sequence and X follows the exponential distribution. B.4.2 Normal Distribution Random Variate There exists no analytical expression for the inverse function of the normal cumulative distribution function. The following approximate expression can be used. Given an area Q(z) under the normal density distribution curve as shown in Fig. A., the corresponding z can be calculated by [2] where and c 0 = 2.5557 c = 0.802853 c 2 = 0.00328 d =.432788 d 2 = 0.89269 d 3 = 0.00308 2 c i s i i=0 z = s + 3 d i s i i= s = 2 l n Q (B.5) (B.6) The maximum error of Equation (B.5) is smaller than 0.45 0 4. The algorithm for generating the normal distribution random variate is stated as follows: Step : Generate a uniform distribution random number sequence R between [0, ].
294 ELEMENTS OF MONTE CARLO SIMULATION Step 2: Calculate the normal distribution random variate X by z X = 0 z if 0.5 < R.0 if R = 0.5 if 0 R < 0.5 (B.7) where z is obtained from Equation (B.5) and Q in Equation (B.6) is given by Q = R R if 0.5 < R.0 if 0 R 0.5 (B.8) B.4.3 Log-Normal Distribution Random Variate According to the basic probability theory, if the random variable Y is a function of the random variable X, that is, y = y(x), then the probability density functions of Y and X have the following relationship: dx f(y) = f(x) dy (B.9) It can be proved from Equation (B.9) that if X follows the normal distribution, then Y = e X follows the log-normal distribution. The algorithm for generating the log-normal distribution random variate is as follows: Step : Generate a random variate Z following the standard normal distribution. Step 2: Let X = + Z, where and are the parameters in the density function of the log-normal distribution. Note that as mentioned in Section A.3.3, they are not the mean and standard deviation of the log-normal distribution. Step 3: Let Y = e X, where Y is a log-normally distributed random variate. B.4.4 Weibull Distribution Random Variate By using the inverse transform method, let a uniform distribution random number R equal the Weibull cumulative probability distribution function, which is given by Equation (A.28): x R = F(x) = exp (B.20) Equivalently, X = [ ln( R)] / (B.2)
B.4 IMPORTANT RANDOM VARIATES IN RISK EVALUATION 295 Since ( R) distributes uniformly in the same way as R in the interval [0, ], Equation (B.2) becomes X = ( ln R) / (B.22) The algorithm for generating the Weibull distribution random variate is as follows: Step : Generate a uniform distribution random number sequence R between [0, ]. Step 2: Calculate the Weibull distribution random variate X using Equation (B.22).