
22 CHAPTER 1 Classifiers Based on Bayes Decision Theory
or
V(x) =
4
3
πρ
3
in the 3-dimensional space
For the more general case of l dimensions and/or Mahal anobis distance, see [Theo 09, Section 2.5.6].
Example 1.8.1. Consider the data set generated in Example 1.7.1 and use the k-nearest neighbor
density estimator to estimate the required pdf with k = 21.
Solution. To generate the set X of the data vectors, work as in Example 1.7.1. Assuming that we
are interest ed in approximating the pdf for x ∈[−5, 5] (as in Example 1.7.1), we use the funct i on
knn_density_estimate, typing
pdfx_approx=knn_density_estimate(X,21,-5,5,0.1);
plot(-5:0.1:5,pdfx_approx,'r'