Kdensity

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search

Purpose

Calculates the kernel density estimate.

Synopsis

[kde, newx] = kdensity(x,code,width,n,at)

Description

Produces the kernel density estimate of the data contained in the input vector (x) which must be real.

Inputs

  • x = The name of a matrix (column vector) in which the sample data is stored.
  • code = Integer between 1 and 7 indicating which kernel to use.
1 - Bivwight
2 - Cosine
3 - Epanechnikov {default}
4 - Gaussian
5 - Parzen
6 - Triangle
  • width = scalar, optional window width to use in the kernel calculation. If not specified, then the optimal window width is used according to the calculation:
  • n = scalar, number of points at which to estimate the density.
  • at = vector, allows the user to specify a vector of points at which the density should be estimated. By using this option, it makes it easier to overlay density estimates for different samples on the same graph.

Outputs

  • newx = x input returned.
  • kde = The return value is a structure with fields:
    • x = vector of points where density was estimated. Will be the same as 'at' input if used.
    • fx = ?
    • n = number of points at which to estimate density. Same as 'n' input if used.
    • width = window width used. Same as 'width' input if used.
    • kernel = name of kernel used.

Examples

 kde = kdensity(x,2);
 kde = kdensity(x,2,22.4);
 kde = kdensity(x,2,22.4,50);
 kde = kdensity(x,2,22.4,50,y);

See Also

plotkd