SIMULATION MODELING AND ANALYSIS WITH ARENA T. Altiok and B. Melamed Chapter 4 Random Number and Variate Generation

202 Views

Download Presentation
## SIMULATION MODELING AND ANALYSIS WITH ARENA T. Altiok and B. Melamed Chapter 4 Random Number and Variate Generation

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -

**SIMULATION MODELING AND ANALYSIS WITH ARENA**T. Altiok and B. Melamed Chapter 4 Random Number and Variate Generation Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**Random Number Generators**• Random Number Generators (RNG) are used to introduce randomness into Monte Carlo simulation • An RNG is an algorithm that generates a stream of pseudo-random numbers, depending on some parameters and an initial seed • Each stream “looks” random, but can be exactly reproduced from the initial seed • Basic RNGs typically produce uniformly distributed sequences, and other distributions are often obtained by their transformation Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**Linear Congruential Generators**• Generation algorithm has the form • where • the initial value , called the seed (or initialseed), must be chosen with care (provided as part of the RNG) • the operation returns the remainder of • the resulting pseudo-random integer sequence is in the range • to convert this sequence to a standard RNG sequence in the range , one uses the transformation Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**Step**Step 0 0 3 3 3/8=0.375 3/8=0.375 1 1 6 6 0.750 0.750 2 2 5 5 0.625 0.625 3 3 0 0 0.000 0.000 4 4 7 7 0.875 0.875 5 5 2 2 0.250 0.250 6 6 1 1 0.125 0.125 7 7 4 4 0.500 0.500 8 8 3 3 0.375 0.375 9 9 6 6 0.750 0.750 10 10 5 5 0.625 0.625 Example: Linear Congruential RNG Random numbers generated by a linear congruential RNG with and Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**The Inverse Transform Method**(a) Every cdf, , is non-decreasing, so the inverse cdf, , is always well defined (b) Applying the distribution function, , to the underlying variate, , results in a variate , uniform between 0 and 1 (c) Conversely, applying an inverse distribution function to a Unif(0,1) variate, , results in a variate with cdf (d) The Inverse Transform method uses (a) – (c) in a two-step algorithm: 1. Use your favorite RNG to generate a realization from a variate, 2. Compute as a realization of X Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**1**0 The Inverse Transform Method (Cont.) Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**Generation of Uniform Variates**• 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 • Recall that the uniform cdf can be rewritten as • where u is given and x is unknown • Solving the above for x to obtain the inverse cdf readily yields the formula • and substituting and into the above results in the requisite value Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**Generation of Exponential Variates**• Suppose we wish to generate a realization x from the exponential distribution Expo(0.5) of rate (mean 2), for a realization of the underlying RNG. • Recall that the cdf of the exponential distribution can be written as , where u is given and xis unknown • Solving the above for x readily yields the formula • and substituting and above results in the requisite value • Since implies , it follows that the equation above may be simplified into the equivalent formula Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**Generation of Discrete Variates**Suppose we code the state space by integers, say, S = {1,2,…}, and we wish to generate a realization x from a discrete pdf over S as in the table below • Recall that the discrete cdf can be rewritten as Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**Generation of Discrete Variates (Cont.)**Utilizing the general formula for an inverse cdf, we deduce that the inverse cdf can be written as where or equivalently, such that In our case, we have Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**Generation of Step Variates**Suppose we wish to generate a realization x from a step distribution with J = 4 steps, whose pdf is specified in the table below Recall that the step cdf can be rewritten as Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**Generation of Step Variates (Cont.)**Solving the cdf for x yields the inverse step cdf where It follows that the requisite variate realization x, corresponding to u = 0.5 is Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**1.00**0.80 0.45 0.30 3 0 1 2 4 Generation of Step Variates (Cont.) The Inverse Transform method for generating a variate with a step pdf Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**Generation of General Processes**Generating general processes (non-iid) that follow a prescribed probability law is hard. More specifically, the problem is two-fold: 1. To specify a probability law for a process, one must specify the temporal dependence of the process in the form of joint distributions of any dimension. Except for special cases (when dependence does not extend arbitrarily far into the past), this approach can be impractical. 2. When temporal dependence cannot be estimated in terms of joint distributions, one may elect to use a statistical proxy of temporal dependence, often in the form of autocorrelations. Even when the process to be modeled is stationary, the problem of devising a model that fits the observed (empirical) autocorrelations and marginal distribution, simultaneously, it is non-trivial. To illustrate the complexity inherent in the first problem, we outline an algorithm for generating a general stochastic sequence, with a real valued state space, S. Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4**General Generation Algorithm**Input: a probability law L for a general random sequence , given by Output: A sample path (realization) from the probability law L. Algorithm: 1. Apply the Inverse Transform method to the initial seed, , to get 2. Suppose have already been generated from seeds . Then use the Inverse Transform method to generate the next variate , where is the next seed 3. Continue analogously as necessary… Altiok / Melamed Simulation Modeling and Analysis with Arena Chapter 4