# 3.5.3.2.8 Ks2density

## Definition:

z = ks2density(x, y, vX, vY, wx, wy) returns the 2D kernel density at point (x, y) with respect
to a function established by datasets (vX, vY) with scale (wx, wy), where scale (wx, wy) are determined by estimation function Kernel2width.

$\text{ks2density}(x,y,\text{vX},\text{vY},w_x,w_y) = \frac{1}{n} \sum_{i=1}^{n} \frac{1}{ 2\pi w_x w_y } \exp \left(-\frac{(x-\text{vX}_i)^2}{2w_x ^2} - \frac{(y-\text{vY}_i)^2}{2w_y^2} \right)$

where n is the number of elements in vector vX or vY, $\text{vX}_i$ is ith element in vector vX and $\text{vY}_i$ is ith element in vector vY.

## Parameters:

$x$ (input, double)
x value to evaluate for 2D kernel density
$y$ (input, double)
y value to evaluate for 2D kernel density
$\text{vX}$ (input, vector)
x values of distributed samples used as kernel centers
$\text{vY}$ (input, vector)
y values of distributed samples used as kernel centers
$w_x$ (input, double)
The bandwidth of X scale, $w_x > 0$
$w_y$ (input, double)
The bandwidth of Y scale, $w_y > 0$
$z$ (output, double)
2D kernel density at point $(x,y)$ with respect to a function established by datasets (vX,vY) with scale $(w_x,w_y)$