
7.9 STATISTICS OF POINT DISTRIBUTIONS 219
7 SPATIAL DATA
pected frequencies (Section 3.8). e quantity χ
2
is de ned as the sum of the
squared di erences divided by the expected frequencies.
chi2_data = sum((n_obs - n_exp).^2 ./n_exp)
chi2 =
14
e critical χ
2
can be calculated by using chi2inv. e χ
2
-test requires the
degrees of freedom Φ. In our example, we test the hypothesis that the data
are uniformly distributed, i.e., we estimate only one parameter (Section 3.4).
e number of degrees of freedom is therefore Φ=25–(1+1)=23. We test
the hypothesis at a p=95 % signi cance level. e function
chi2inv com-
putes the inverse of the χ
2
CDF with parameters speci ed by Φ for the cor-
responding probabilities in p.
chi2_theo = chi2inv(0.95,25-1-1)
ans =
35.1725
Since the critical χ
2
of 35.1725 is well above the measured χ
2
of 14, we can-
not reject the null hypothesis and conclude that our data follow a uniform
distribution.
Test for Random Distribution
e following example illustrates the test for random distribution of objects
within an area. We use the uniformly-distributed data generated in the pre-
vious example and display the point distribution.
clear
rand('seed',0)
data = 10 * rand(100,2);
plot(data(:,1),data(:,2),'o')
hold on
x = 0:10; y = ones(size(x));
for i = 1:9, plot(x,i*y,'r-'), end
for i = 1:9, plot(i*y,x,'r-'), end
hold off
We generate the three-dimensional histogram and use the function hist3
to count the objects per class. In contrast to the previous test, we now count
the subareas containing a certain number of observations. e number of
subareas is larger than would usually be used for the previous test. In our
example, we use 49 subareas or classes.