Different type of kernel functions.

kern(u, type='epk')

Arguments

u

a numeric vector, evluated points in kernel funciton.

type

a optional character string, specify the type of used kernel functionand support 'epk', 'biweight', 'triangle', 'guassian', 'triweight', 'tricube', 'cosine', 'uniform' in current version, defualt as 'epk'.

Details

Note that K(u_i)=K(X_i-x_0) where u = (X_1-x_0, ..., X_n-x_0) and K_h(u_i)=1/h*K((X_i-x_0)/h) where h is bandwidth.

Value

Return a numeric vector with length equal to 'u'.

Author

Liu Wei

See also

KernSmooth package

Examples

library(graphics) u <- seq(-1,1,by=0.01) (Ku <- kern(u))
#> [1] 0.000000 0.014925 0.029700 0.044325 0.058800 0.073125 0.087300 0.101325 #> [9] 0.115200 0.128925 0.142500 0.155925 0.169200 0.182325 0.195300 0.208125 #> [17] 0.220800 0.233325 0.245700 0.257925 0.270000 0.281925 0.293700 0.305325 #> [25] 0.316800 0.328125 0.339300 0.350325 0.361200 0.371925 0.382500 0.392925 #> [33] 0.403200 0.413325 0.423300 0.433125 0.442800 0.452325 0.461700 0.470925 #> [41] 0.480000 0.488925 0.497700 0.506325 0.514800 0.523125 0.531300 0.539325 #> [49] 0.547200 0.554925 0.562500 0.569925 0.577200 0.584325 0.591300 0.598125 #> [57] 0.604800 0.611325 0.617700 0.623925 0.630000 0.635925 0.641700 0.647325 #> [65] 0.652800 0.658125 0.663300 0.668325 0.673200 0.677925 0.682500 0.686925 #> [73] 0.691200 0.695325 0.699300 0.703125 0.706800 0.710325 0.713700 0.716925 #> [81] 0.720000 0.722925 0.725700 0.728325 0.730800 0.733125 0.735300 0.737325 #> [89] 0.739200 0.740925 0.742500 0.743925 0.745200 0.746325 0.747300 0.748125 #> [97] 0.748800 0.749325 0.749700 0.749925 0.750000 0.749925 0.749700 0.749325 #> [105] 0.748800 0.748125 0.747300 0.746325 0.745200 0.743925 0.742500 0.740925 #> [113] 0.739200 0.737325 0.735300 0.733125 0.730800 0.728325 0.725700 0.722925 #> [121] 0.720000 0.716925 0.713700 0.710325 0.706800 0.703125 0.699300 0.695325 #> [129] 0.691200 0.686925 0.682500 0.677925 0.673200 0.668325 0.663300 0.658125 #> [137] 0.652800 0.647325 0.641700 0.635925 0.630000 0.623925 0.617700 0.611325 #> [145] 0.604800 0.598125 0.591300 0.584325 0.577200 0.569925 0.562500 0.554925 #> [153] 0.547200 0.539325 0.531300 0.523125 0.514800 0.506325 0.497700 0.488925 #> [161] 0.480000 0.470925 0.461700 0.452325 0.442800 0.433125 0.423300 0.413325 #> [169] 0.403200 0.392925 0.382500 0.371925 0.361200 0.350325 0.339300 0.328125 #> [177] 0.316800 0.305325 0.293700 0.281925 0.270000 0.257925 0.245700 0.233325 #> [185] 0.220800 0.208125 0.195300 0.182325 0.169200 0.155925 0.142500 0.128925 #> [193] 0.115200 0.101325 0.087300 0.073125 0.058800 0.044325 0.029700 0.014925 #> [201] 0.000000
plot(u, Ku, type='l')
# guassian kernel plot(u, kern(u, type='gaussian'), type ='l')
# cosine kernel plot(u, Ku <- kern(u, type='cosine'), type ='l')