Page 85 - Computational Statistics Handbook with MATLAB
P. 85

Chapter 3: Sampling Concepts                                     71


                                                             q
                                                              0.5
                                                       0.5 =  ∫  fx()d  . x                (3.42)
                                                             – ∞

                             We can get a measure of the dispersion of the random variable by looking at
                             the interquartile range (IQR) given by

                                                      IQR =  q 0.75 –  q 0.25 .            (3.43)


                              One way to obtain an estimate of the quantiles is based on the empirical
                                                          ,    ,  ,
                             distribution function. If we let X 1() X 2() … X n()  denote the order statistics for
                                                             is an estimate of the  j –(  ⁄
                             a random sample of size n, then X j()                0.5) n   quantile
                             [Banks, 2001; Cleveland, 1993]:

                                                             1 j –
                                                                  0.5
                                                       X j() ≈  F –   ---------------    .  (3.44)
                                                                 n
                             We are not limited to a value of 0.5 in Equation 3.44. In general, we can esti-
                             mate the p-th quantile using the following

                                                                 j
                                                                            ,
                                                        ---------- <
                                                                               ,
                                           ˆ
                                          q p =  X ;    j –  1  p ≤  ---;  j =  1 … n  .   (3.45)
                                                 j ()
                                                         n       n
                              As already stated, Equation 3.45 is not the only way to estimate quantiles.
                             For more information on other methods, see Kotz and Johnson [Vol. 7, 1986].
                             The analyst should exercise caution when calculating quartiles (or other
                             quantiles) using computer packages. Statistical software packages define
                             them differently [Frigge, Hoaglin, and Iglewicz, 1989], so these statistics
                             might vary depending on the formulas that are used.

                             EXAMPLE 3.5
                             In this example, we will show one way to determine the sample quartiles.
                                                      ˆ
                             The second sample quartile q 0.5   is the sample median of the data set. We can
                             calculate this using the function median. We could calculate the first quartile
                             ˆ
                             q 0.25   as the median of the ordered data that are at the median or below. The
                                         ˆ
                             third quartile  q 0.75   would be calculated as the median of the data that are at
                             ˆ
                             q 0.5   or above. The following MATLAB code illustrates these concepts.
                                % Generate the random sample and sort.
                                x = sort(rand(1,100));
                                % Find the median of the lower half - first quartile.
                                q1 = median(x(1:50));
                                % Find the median.
                                q2 = median(x);


                            © 2002 by Chapman & Hall/CRC
   80   81   82   83   84   85   86   87   88   89   90