mvksdensity
statistics: f = mvksdensity (x, pts, Name, Value)
Multivariate kernel smoothing density estimate.
f = mvksdensity (x, pts) computes a probability
density estimate of the sample in the matrix x, evaluated at
the points in the matrix pts. Each row of x is a
single -dimensional observation, and each row of pts is a point
at which to evaluate the estimate. The result f is an
vector, with one density value per row of pts.
The density estimate uses a product kernel: the multivariate kernel is the product of the univariate kernels applied to each dimension, each with its own bandwidth.
The following Name-Value pairs are supported:
| Name | Value |
|---|---|
'Bandwidth' | The kernel bandwidth, either a positive scalar applied to every dimension or a vector of positive values, one per dimension. The default is a diagonal normal-reference (Silverman) rule computed from x. |
'Kernel' | The smoothing kernel applied in each dimension:
'normal' (default), 'box', 'triangle', or
'epanechnikov'. |
'Function' | The function to estimate: 'pdf'
(default) or 'cdf'. |
'Weights' | A vector of non-negative weights, one for each row of x. The default weights are all equal. |
Source Code: mvksdensity
See also: ksdensity
Source Code: mvksdensity
Bivariate kernel density estimate over a grid, drawn as a contour plot.
x = [randn(60, 2); randn(40, 2) + 3];
[gx, gy] = meshgrid (linspace (-4, 7, 60));
f = mvksdensity (x, [gx(:), gy(:)]);
contourf (gx, gy, reshape (f, size (gx)));
hold on; plot (x(:,1), x(:,2), 'k.'); hold off;
title ('Bivariate kernel density estimate');