Page 64 - MATLAB Recipes for Earth Sciences
P. 64

3.6 The F–Test                                                   55

             ssmaller =
                 1.2097

           Now we compare the calculated F with the critical F. This can be accom-
           plished using the function finv on a 95% signifi cance level. The function
           finv returns the inverse of the F distribution function with df1 and df2
           degrees of freedom, at the value of 0.95. Typing
             Freal = slarger^2/ssmaller^2

             Ftable = finv(0.95,df1,df2)
           yields

             Freal =
                 1.0762

             Ftable =
                 1.5400

           The F calculated from the data is smaller than the critical F. We therefore
           cannot reject the null hypothesis without another cause. The variances are
           identical on a 95% signifi cance level.
             We now apply this test to two distributions with very different standard
           deviations, 2.0 and 1.2, respectively.

             load('organicmatter_five.mat');

           Now we compare the calculated F with the critical F at a 95% signifi cance
           level. The critical F can be computed using the function finv. We again type

             s1 = std(corg1);
             s2 = std(corg2);

             df1 = length(corg1) - 1;
             df2 = length(corg2) - 1;

             if s1 > s2
               slarger  = s1;
               ssmaller = s2;
             else
               slarger  = s2;
               ssmaller = s1;
             end
             Freal = slarger^2/ssmaller^2

             Ftable = finv(0.95,df1,df2)
   59   60   61   62   63   64   65   66   67   68   69