Page 63 - MATLAB Recipes for Earth Sciences
P. 63

54                                                 3 Univariate Statistics

               Although MATLAB does not provide a ready-to-use F–test, this hypoth-
            esis test can easily be implemented. We fi rst apply this test to two distribu-
            tions with very similar standard deviations of 1.3 and 1.2, respectively.

               load('organicmatter_four.mat');


            The quantity F is defined as the quotient between the larger and the smaller
            variance. First we compute the standard deviations, where
               s1 = std(corg1)

               s2 = std(corg2)
            yields

               s1 =
                   1.2550
               s2 =
                   1.2097

            The F–distribution has two parameters, df1 and df2, which are the num-
            bers of observations of both distributions reduced by one, where
               df1 = length(corg1) - 1

               df2 = length(corg2) - 1
            yields

               df1 =
                   59

               df2 =
                   59

            Next we sort the standard deviations by their absolute value,
               if s1 > s2
                 slarger  = s1
                 ssmaller = s2
               else
                 slarger  = s2
                 ssmaller = s1
               end
            and get

               slarger =
                   1.2550
   58   59   60   61   62   63   64   65   66   67   68