1
Random Variate
Generation
                 Presented by – Ritu Raj
                                                                     2
                                       1.    Radom Variate
                                       2.    Inverse-transform Technique
      Overview                         3.    Acceptance-rejection Technique
                                       4.    Composition Method
                                       5.    Convolution Method
                                       6.    Summary
SSE              Random Variate Generation                               Ritu Raj
                                                                                           3
      Random Variate
         A random variate is a variable generated from uniformly distributed
          pseudorandom numbers. Depending on how they are generated, a
          random variate can be uniformly or nonuniformly distributed.
         “In the mathematical fields of probability and statistics, a random variate is
          a particular outcome of a random variable”.
         Random variates are frequently used as the input to simulation models.
SSE                                            Random Variate Generation                       Ritu Raj
                                                                                        4
          Preparation
         It is assumed that a source of uniform [0,1] random numbers exists.
          • Linear Congruential Method (LCM)
         Random numbers 𝑅, 𝑅1 , 𝑅2 , … with
          • PDF
                              0   0≤𝑥≤1
                   𝑓𝑅 𝑥 = ቊ
                              1   otherwise
          • CDF
                             0          x<1
                    𝐹𝑅 𝑥 = ቐ x        0≤𝑥≤1                           fig.1 pdf   fig.2 cdf
                             1          𝑥>1
SSE                                              Random Variate Generation                    Ritu Raj
                                                                                                           5
      Inverse-transform Technique
         The concept:
          • For CDF function: r = F(x)
          • Generate r from uniform (0,1), a.k.a U(0,1)
          • Find x, x = 𝐹 −1 (r)
                                             F(x)                                                   F(x)
                                                                         Figure3 random variate   [1]
SSE                                          Random Variate Generation                                         Ritu Raj
                                                                                          6
      Inverse-transform Technique
          The inverse-transform technique can be used in principle for any
           distribution.
          Most useful when the CDF F(x) has an inverse 𝐹 −1 (x), which is easy to
           compute.
          Required steps:
                1.   Compute the CDF of the desired random variable X
                2.   Set F(X) = R on the range of X
                3.   Solve the equation F(X) = R for X in terms of R
                4.   Generate uniform random numbers 𝑅1 , 𝑅2 , 𝑅3 , ... and compute the
                     desired random variate by 𝑥𝑖 = 𝐹 −1 𝑅𝑖
SSE                                              Random Variate Generation                    Ritu Raj
                                                                               7
      Applications of the Inverse
      Transformation Technique
                  Table 1 Application of Inverse Transformation Technique[2]
SSE                                  Random Variate Generation                     Ritu Raj
                                                                                8
      Acceptance-Rejection Technique
         Useful particularly when inverse CDF does not exist in closed form.
         Can be used if a pdf g(x) exists such that c g(x) majorizes the
          pdf f(x) ⇒ c g(x) > f(x) ∀ x
         Required steps :
          1.   Generate x with pdf g(x).
          2.   Generate y uniform on [0, cg(x)].
          3.   If y < f(x), then output x and return.
           Otherwise, repeat from step 1.
          4.   Continue rejecting the random variates x and y until y > f(x)
SSE                                                 Random Variate Generation       Ritu Raj
                                                                                                 9
      g is a Nice" Majorizing function,
      can say Uniform.
      Throw darts at rectangle under g
      until hit f
      Prob {Accept X} is proportional
      to height of f (X) - called trial
      ratio
                                                                      Figure4 Accept-Rejection
SSE                                       Random Variate Generation                                  Ritu Raj
                                                                            10
      Composition Method
         Can be used if CDF F(x) = Weighted sum of n other CDFs.
                                          𝑛
                                  𝐹 𝑥 =  𝒑𝑖 𝐹𝑖 𝑥
                                         𝑖=1
         Here, 𝒑𝑖 ≥ 𝟎, σ𝑛𝑖=1 𝒑𝑖 = 𝟏 𝒂𝒏𝒅 𝐹𝑖′𝑠 are distribution functions.
         n CDFs are composed together to form the desired CDF
          Hence, the name of the technique.
         The desired CDF is decomposed into several other CDFs
          ⇒ Also called decomposition.
         Can also be used if the pdf f(x) is a weighted sum of n other
          pdfs:                   f 𝑥 = σ𝑛𝑖=1 𝒑𝑖 𝒇𝑖 𝑥
SSE                                             Random Variate Generation    Ritu Raj
                                                                              11
      Composition Method
          Required steps :
      1.   Generate a random integer I such that:
                                  𝑃 𝐼 = i = 𝑝𝑖
      2.   This can easily be done using the inverse-transformation method.
      3.   Generate x with the 𝑖 𝑡ℎ pdf 𝒇𝑖 𝑥 and return.
SSE                                           Random Variate Generation        Ritu Raj
                                                                          12
      Convolution Method
         Convolution
           • The sum of independent random variables
      o   Sum of n variables: 𝑥 = 𝑦1 + 𝑦2 + 𝑦3 + ⋯ + 𝑦𝑛
      o   Generate n random variate 𝒚𝑖 's and sum
      o   For sums of two variables, pdf of x = convolution of
           pdfs of 𝑦1 and 𝑦2 . Hence the name
      o   Although no convolution in generation
SSE                                           Random Variate Generation    Ritu Raj
                                                                         13
      Convolution Method
      o   If, pdf or CDF = Sum ⇒ Composition
      o   Variable x = Sum ⇒ Convolution
                              𝒇 ∗ 𝒈 𝒕 = න 𝒇 𝝉 𝒈 𝒕 − 𝝉 𝒅𝝉
                                       −∞
         Can be applied to obtain
          • Erlang variates
          • Binomial variates
SSE                                          Random Variate Generation    Ritu Raj
                                                                     14
      Summary
        Is CDF         Yes
        invertible?
                                                    Use inversion
          Is CDF a     Yes
        sum of other                               Use composition
            CDFs?
SSE                    Random Variate Generation                      Ritu Raj
                                                                              15
      Is pdf a sum
                     Yes
         of other                                       Use Composition
          pdfs?
         Is the
       variate a     Yes
        sum of                                           Use convolution
         other
       Variates?
          Is the
         Variate     Yes
       related to                                      Use characterization
          other
        variates?
SSE                        Random Variate Generation                           Ritu Raj
                                                                              16
Continue...
              Does
          a majorizing            Yes
            function
                                                              Use rejection
              exist?
           NO
        Use empirical inversion
  SSE                             Random Variate Generation                    Ritu Raj
                                                                                             17
References
[1] Modeling and Performance Analysis with Simulation
Available: https://www.mi.fu-berlin.de/inf/groups/ag-
tech/teaching/2012_SS/L_19540_Modeling_and_Performance_Analysis_with_Simulation/index.html
[2] Random Variate Generation
Available: https://www.cse.wustl.edu/~jain/cse567-08/k_28rvg.htm
Reading References:
1. Introduction to Discrete Event Systems by Christos G. Cassandras and Stéphane Lafortune
2.   Wikipedia: https://en.wikipedia.org/wiki/Random_variate
3.   Simulation CSCI 6637: https://www.eg.bucknell.edu/~xmeng/Course/CS6337/Note/master/
18