Kdensity: Difference between revisions
Jump to navigation
Jump to search
imported>Jeremy (Importing text file) |
imported>Jeremy (Importing text file) |
||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Calculates the kernel density estimate. | Calculates the kernel density estimate. | ||
===Synopsis=== | ===Synopsis=== | ||
:[kde, newx] = kdensity(x,code,width,n,at) | :[kde, newx] = kdensity(x,code,width,n,at) | ||
===Description=== | ===Description=== | ||
Produces the kernel density estimate of the data contained in the input vector (x) which must be real. | Produces the kernel density estimate of the data contained in the input vector (x) which must be real. | ||
====INPUTS==== | ====INPUTS==== | ||
* '''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 | * '''1''' - Bivwight | ||
* '''2''' - Cosine | * '''2''' - Cosine | ||
* '''3''' - Epanechnikov {default} | * '''3''' - Epanechnikov {default} | ||
* '''4''' - Gaussian | * '''4''' - Gaussian | ||
* '''5''' - Parzen | * '''5''' - Parzen | ||
* '''6''' - Triangle | * '''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. | **''''''''''''''' 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. | ||
====OUTPUTS==== | ====OUTPUTS==== | ||
* '''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 15:25, 3 September 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);