Page 120 - Computational Statistics Handbook with MATLAB
P. 120

Chapter 4: Generating Random Variables                          107


                              Another function that might prove useful in implementing computational
                             statistics methods is called randperm. This is provided with the standard
                             MATLAB software package, and it generates random permutations of the
                             integers 1 to n. The result can be used to permute the elements of a vector. For
                             example, to permute the elements of a vector x of size n, use the following
                             MATLAB statements:

                                % Get the permuted indices.
                                ind = randperm(n);
                                % Now re-order based on the permuted indices.
                                xperm = x(ind);
                              We also provide some functions in the Computational Statistics Toolbox for
                             generating random variables. These are outlined in Table 4.2. Note that these
                             generate random variables using the distributions as defined in Chapter 2.


                                   T
                                    A
                                   T
                                    A
                                         4
                                         4.2
                                          .2
                                          .2
                                       E
                                     B
                                     B
                                       E
                                      L
                                   T
                                   TA AB  BL LE L E4  4 .2
                                   List of Functions from Chapter 4 Included in the Computational
                                   Statistics Toolbox
                                          Distribution              MATLAB Function
                                   Beta                               csbetarnd
                                   Binomial                            csbinrnd
                                   Chi-Square                          cschirnd
                                   Discrete Uniform                    csdunrnd
                                   Exponential                         csexprnd
                                   Gamma                               csgamrnd
                                   Multivariate Normal                 csmvrnd
                                   Poisson                             cspoirnd
                                   Points on a sphere                  cssphrnd


                             4.6 Further Reading

                             In this text we do not attempt to assess the computational efficiency of the
                             methods for generating random variables. If the statistician or engineer is
                             performing extensive Monte Carlo simulations, then the time it takes to gen-
                             erate random samples becomes important. In these situations, the reader is
                             encouraged to consult Gentle [1998] or Rubinstein [1981] for efficient algo-
                             rithms. Our goal is to provide methods that are easily implemented using
                             MATLAB or other software, in case the data analyst must write his own func-
                             tions for generating random variables from non-standard distributions.

                            © 2002 by Chapman & Hall/CRC
   115   116   117   118   119   120   121   122   123   124   125