Library: | kernel |
See also: | rkernpq rqua rtri rtrian runi epa |
Quantlet: | repa | |
Description: | computes the radial symmetric epanechnikov kernel |
Usage: | y = repa (x) | |
Input: | ||
x | n x d matrix of user-defined data for which the kernel is to be computed | |
Output: | ||
y | n x 1 matrix containing the radial epanechnikov kernel |
library("kernel") ; load library kernel d = 3 ; choose dimension n = 1000 ; choose n points uniformly in [-1,1]^d x = 2*uniform(n,d)-1 y = repa(x) ; compute kernel values ; approximate the integral about the kernel ; function in [-1,1]^d sum(y.*2^d/n)
Independent of d you should get approximately 1 as result. Note that for higher dimensions n has to be increased!
library("kernel") ; load kernel library library("plot") ; load plot library d = 2 ; choose dimension o = matrix(d) ; create uniform grid in [-1,1]^d n = 50.*o h = 2/(n-1).*o x0 = -o x = grid(x0, h, n) y = repa(x) ; compute kernel values plot(x~y) ; show kernel function(d<3)
Shows the radial Epanechnikov kernel. Note that d can only take the values d=1 or d=2 to show something useful!