Kdensity: Difference between revisions
Jump to navigation
Jump to search
imported>Jeremy (Importing text file) |
imported>Jeremy No edit summary |
||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Line 15: | Line 14: | ||
* '''x''' = The name of a matrix (column vector) in which the sample data is stored. | * '''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. | * '''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: | * '''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. | * '''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. | ||
Line 41: | Line 29: | ||
* '''newx''' = x input returned. | * '''newx''' = x input returned. | ||
* '''kde''' = The return value is a structure with fields. | * '''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. | * '''x''' = vector of points where density was estimated. Will be the same as 'at' input if used. | ||
* '''fx''' = ? | * '''fx''' = ? | ||
* '''n''' = number of points at which to estimate density. Same as 'n' input if used. | * '''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. | * '''width''' = window width used. Same as 'width' input if used. | ||
* '''kernel''' = name of kernel used. | * '''kernel''' = name of kernel used. | ||
===Examples=== | ===Examples=== | ||
kde = kdensity(x,2); | kde = kdensity(x,2); | ||
kde = kdensity(x,2,22.4); | kde = kdensity(x,2,22.4); | ||
kde = kdensity(x,2,22.4,50); | kde = kdensity(x,2,22.4,50); | ||
kde = kdensity(x,2,22.4,50,y); | kde = kdensity(x,2,22.4,50,y); | ||
===See Also=== | ===See Also=== | ||
[[plotkd]] | [[plotkd]] |
Revision as of 16:35, 9 October 2008
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);