1 # Copyright (C) 2006 Michael Creel <michael.creel@uab.es>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; If not, see <http://www.gnu.org/licenses/>.
16 # __kernel_epanechnikov: this function is for internal use by kernel_density
17 # and kernel_regression
19 # multivariate spherical Epanechnikov kernel
20 # input: PxK matrix - P data points, each of which is in R^K
21 # output: Px1 vector, input matrix passed though the kernel
22 # other multivariate kernel functions should follow this convention
24 function z = __kernel_epanechnikov(z)
28 # Volume of d-dimensional unit sphere
29 c = pi ^ (K/2) / gamma(K/2 + 1);
33 z = ((1/2) / c * (K + 2) * (1 - z)) .* (z < 1);