Page 101 - Computational Statistics Handbook with MATLAB
P. 101

88                         Computational Statistics Handbook with MATLAB


                             PROCEDURE - REJECTION METHOD (DISCRETE)

                                                                     that is easy to sample from.
                                1. Choose a probability mass function  q i
                                2. Find a constant c such that  p Y <  cq Y  .
                                                                               .
                                3. Generate a random number Y from the density  q i
                                4. Generate a uniform random number U.
                                5. If


                                                           U ≤  --------  ,
                                                               p Y
                                                              cq Y
                                   then deliver X =  Y , else go to step 3.


                             Example 4.5
                             In this example, we use the discrete form of the acceptance-rejection method
                             to generate random variables according to the probability mass function
                             defined as follows
                                                        (
                                                       PX =  1) =  0.15,
                                                        (
                                                       PX =  2) =  0.22,
                                                        (
                                                       PX =  3) =  0.33,
                                                        (
                                                       PX =  4) =  0.10,
                                                        (
                                                       PX =  5) =  0.20.
                                      be the discrete uniform distribution on  1 … 5,  ,
                             We let  q Y                                       , where the proba-
                             bility mass function is given by

                                                        1
                                                                    ,
                                                        -
                                                   q y =  --;  y =  1 …,  . 5
                                                        5
                             We describe a method for generating random variables from the discrete uni-
                             form distribution in a later section. The value for c is obtained as the maxi-
                                            ⁄
                             mum value of  p y q y  , which is 1.65. This quantity is obtained by taking the
                                         , which is PX =(
                             maximum p y                3) =  0.33  , and dividing by 1/5:
                                                  max p y )
                                                      (
                                                  --------------------- =  0.33 ×  5 =  1.65  .
                                                      ⁄
                                                    15
                             The steps for generating the variates are:





                            © 2002 by Chapman & Hall/CRC
   96   97   98   99   100   101   102   103   104   105   106