y=ksdensity(x, vX, w) returns the kernel density at x for a given vector vX with a bandwidth w, where an optimal w can be determined by the estimation function kernelwidth.

\text{ksdensity}(x, \text{vX}, \text{w})=\frac{1}{ n\text{w} } \sum_{i=1}^n K \left( \frac{x-\text{vX}_i}{ \text{w} } \right)

where n is the size of vector vX, K is the kernel function, Origin uses normal (Gaussian) kernel function, K(x)=\frac{1}{\sqrt{2\pi}}e^{-\frac{x^2}{2}}, and \text{vX}_i is the ith element in vector vX.


x (input, double)
The value to be evaluated for density
\text{vX} (input, vector)
Distributed samples used as kernel centers
\text{w} (input, double)
Bandwidth used as kernel scale, \text{w} > 0
y (output, double)
Kernel density


Wand, M.P. and Jones, M.C. (1995). Kernel Smoothing. Chapman & Hall, London.