Geoscience Reference
In-Depth Information
higher than the critical
KS
value.
As an example we can again test the hypothesis that our organic carbon
measurements contained in
organicmatter_one.txt
follow a Gaussian
distribution. We must i rst load and standardize the data to have zero mean
and unit standard deviation.
clear
corg = load('organicmatter_one.txt');
corg = (corg-mean(corg))/std(corg);
We then compute the empirical distribution function
cn_obs
of
corg
evaluated
at the points
x
by using the function
ecdf
[cn_obs,x] = ecdf(corg);
We then use the function
normcdf
to create the cumulative distribution
function expected from the theoretical distribution
cn_exp
with a mean of
zero and a standard deviation of one.
cn_exp = normcdf(x,0,1);
h e test statistic is the maximum dif erence between the two cumulative
distribution functions
cn_obs
and
cn_exp
kscal = max(cn_obs-normcdf(x,0,1))
which yields
kscalc =
0.0757
We can compare the two cumulative distribution functions in a plot by typing
plot(x,cn_obs,'b'), hold on
plot(x,normcdf(x,0,1),'r')
plot(x(find((cn_obs-normcdf(x,0,1))== ...
max(cn_obs-normcdf(x,0,1))))*ones(2,1),[0 1],'k:')
h e vertical black line marks the location of the maximum dif erence between
the two cumulative distributions. h e critical
kscalc
values are solutions of
an
n
-th order polynomial, which can be obtained from Table 3.1 (O'Connor
and Kleyner 2012). For sample sizes larger than 40 and a signii cance level of
0.05 (or 5%) we calculate
kscrit = 1.36/length(corg)^0.5
which yields