Mathematical Form of Implemented Kernels

January 17, 2014 · View on GitHub

These kernels are designed for use in smoothing algorithms such as kernel regression and kernel density estimation. They are implemented in both unnormalized and normalized form.

Mathematical Form of Implemented Kernels

Currently, the kernels implemented are those found in the Wikipedia article on kernels in statistics.

In normalized form, the kernels are:

  • Uniform: K(u)=12I(u1)K(u) = \frac{1}{2} I(|u| \leq 1)
  • Triangular: K(u)=(1u)I(u1)K(u) = (1 - |u|) I(|u| \leq 1)
  • Epanechnikov: K(u)=34(1u2)I(u1)K(u) = \frac{3}{4} (1 - |u|^2) I(|u| \leq 1)
  • Biweight (Quartic): K(u)=1516(1u2)2I(u1)K(u) = \frac{15}{16} (1 - |u|^2)^2 I(|u| \leq 1)
  • Triweight: K(u)=3532(1u2)3I(u1)K(u) = \frac{35}{32} (1 - |u|^2)^3 I(|u| \leq 1)
  • Tricube: K(u)=7081(1u3)3I(u1)K(u) = \frac{70}{81} (1 - |u|^3)^3 I(|u| \leq 1)
  • Gaussian: K(u)=12πe12u2K(u) = \frac{1}{\sqrt{2 \pi}} e^{-\frac{1}{2}u^2}
  • Cosine: K(u)=π4cos(π2u)I(u1)K(u) = \frac{\pi}{4} \cos(\frac{\pi}{2} u) I(|u| \leq 1)
  • Logistic: K(u)=1eu+2+euK(u) = \frac{1}{e^u + 2 + e^{-u}}

Usage Example

using SmoothingKernels, StatsBase

x = randn(100)

h = StatsBase.bandwidth(x)

λ = 1 / h

kval = λ * SmoothingKernels.kernels[:uniform](λ * (x - 0))
kval = λ * SmoothingKernels.unnormalized_kernels[:uniform](λ * (x - 0))

kval = λ * SmoothingKernels.kernels[:gaussian](λ * (x - 0))
kval = λ * SmoothingKernels.unnormalized_kernels[:gaussian](λ * (x - 0))

To Do

Extend these kernels to work with data points in Rk\mathbb{R}^k and not just R\mathbb{R}.