Page 298 - Computational Statistics Handbook with MATLAB
P. 298
Chapter 8: Probability Density Estimation 287
gridx = ((maxx+2*hx)-(minx-2*hx))/num_pts
gridy = ((maxy+2*hy)-(miny-2*hy))/num_pts
[X,Y]=meshgrid((minx-2*hx):gridx:(maxx+2*hx),...
(miny-2*hy):gridy:(maxy+2*hy));
x = X(:); %put into col vectors
y = Y(:);
We are now ready to get the estimates. Note that in this example, we are
changing the form of the loop. Instead of evaluating each weighted curve and
then averaging, we will be looping over each point in the domain.
z = zeros(size(x));
for i=1:length(x)
xloc = x(i)*ones(n,1);
yloc = y(i)*ones(n,1);
argx = ((xloc-data(:,1))/hx).^2;
argy = ((yloc-data(:,2))/hy).^2;
z(i) = (sum(exp(-.5*(argx+argy))))/(n*hx*hy*2*pi);
end
[mm,nn] = size(X);
Z = reshape(z,mm,nn);
We show the surface plot for this estimate in Figure 8.11. As before, we can
verify that our estimate is a bona fide by estimating the area under the curve.
In this example, we get an area of 0.9994.
area = sum(sum(Z))*gridx*gridy;
Before leaving this section, we present a summary of univariate probability
density estimators and their corresponding Normal Reference Rule for the
smoothing parameter h. These are given in Table 8.2.
8.4 Finite Mixtures
So far, we have been discussing nonparametric density estimation methods
that require a choice of smoothing parameter h. In the previous section, we
showed that we can get different estimates of our probability density
depending on our choice for h. It would be helpful if we could avoid choosing
a smoothing parameter. In this section, we present a method called finite mix-
tures that does not require a smoothing parameter. However, as is often the
case, when we eliminate one parameter we end up replacing it with another.
In finite mixtures, we do not have to worry about the smoothing parameter.
Instead, we have to determine the number of terms in the mixture.
© 2002 by Chapman & Hall/CRC