Page 326 - Computational Statistics Handbook with MATLAB
P. 326

Chapter 8: Probability Density Estimation                       315


                             8.11. In this chapter, we showed how you could construct a kernel density
                                estimate by placing a weighted kernel at each data point, evaluating
                                the kernels over the domain, and then averaging the n curves. In that
                                implementation, we are looping over all of the data points. An alter-
                                native implementation is to loop over all points in the domain where
                                you want to get the value of the estimate, evaluate a weighted kernel
                                at each point, and take the average. The following code shows you
                                how to do this.  Implement  this using the Buffalo  snowfall data.
                                Verify that this is a valid density by estimating the area under the
                                curve.

                                load snowfall
                                x = 0:140;
                                n = length(snowfall);
                                h = 1.06*sqrt(var(snowfall))*n^(-1/5);
                                fhat = zeros(size(x));
                                % Loop over all values of x in the domain
                                % to get the kernel evaluated at that point.
                                for i = 1:length(x)
                                 xloc = x(i)*ones(1,n);
                                 % Take each value of x and evaluate it at
                                 % n weighted kernels -
                                 % each one centered at a data point, then add them up.
                                 arg = ((xloc-snowfall)/h).^2;
                                 fhat(i) = (sum(exp(-.5*(arg)))/(n*h*sqrt(2*pi)));
                                end
                             8.12. Write a MATLAB function that will construct a kernel density esti-
                                mate for the multivariate case.
                             8.13. Write a MATLAB function that will provide the finite mixture den-
                                sity estimate at a point in d dimensions.
                             8.14. Implement the univariate adaptive mixtures density estimation pro-
                                cedure on  the Buffalo  snowfall data. Once you have your initial
                                model, use the EM algorithm to refine the estimate.
                             8.15. In Example 8.13, we generate  a random sample from the kernel
                                estimate of the Old  Faithful  geyser data.  Repeat this example to
                                obtain a new random sample of  geyser data  from the  estimated
                                model and construct a new density estimate from the second sample.
                                Find the integrated squared error between the two density estimates.
                                Does the error between the curves indicate that the second random
                                sample generates a similar density curve?
                             8.16. Say we have a kernel density estimate where the kernel used is a
                                normal density. If we put this in the context of finite mixtures, then
                                                                                      2
                                what are the values for the component parameters (p i , µ i , σ i  ) in the
                                corresponding finite mixture?



                            © 2002 by Chapman & Hall/CRC
   321   322   323   324   325   326   327   328   329   330   331