Geoscience Reference
In-Depth Information
where n a and n b are the sample sizes, and s a 2 and s b 2 are the variances of the
two samples a and b . h e null hypothesis can be rejected if the measured
t -value is higher than the critical t -value, which depends on the number of
degrees of freedom ʦ= n a + n b -2 and the signii cance level ʱ. h e one-tailed
test is used to test against the alternative hypothesis that the mean of the
i rst sample is either smaller or larger than the mean of the second sample
at a signii cance level of 5% (or 0.05). h e one-tailed test would require the
modii cation of the above equation by replacing the absolute value of the
dif erence between the means with the actual dif erence between the means.
h etwo-tailed t -test is used when the means are not equal at a 5% signii cance
level, i.e., when it makes no dif erence which of the means is larger. In this
case, the signii cance level is halved, i.e., 2.5% is used to compute the critical
t -value.
We can now load two example data sets from two independent series
of measurements. h e i rst example shows the performance of the two-
sample t -test on two distributions with means of 25.5 and 25.3 and standard
deviations of 1.3 and 1.5, respectively.
clear
load('organicmatter_two.mat');
h e binary i le organicmatter_two.mat contains two data sets corg1 and corg2 .
First, we plot both histograms in a single graph.
histogram(corg1,'FaceColor','b'), hold on
histogram(corg2,'FaceColor','r'), hold off
We then compute the sample sizes, the means and the standard deviations.
na = length(corg1); nb = length(corg2);
ma = mean(corg1); mb = mean(corg2);
sa = std(corg1); sb = std(corg2);
Next, we calculate the t -value using the translation of the equation for the
t -test statistic into MATLAB code.
tcalc = abs((ma-mb))/sqrt(((na+nb)/(na*nb)) * ...
(((na-1)*sa^2+(nb-1)*sb^2)/(na+nb-2)))
tcalc =
0.7279
We can now compare the calculated tcalc value of 0.7279 with the critical
tcrit value. h is can be accomplished using the function tinv , which yields
the inverse of the t distribution function with na-nb-2 degrees of freedom at
Search WWH ::




Custom Search