Kdensity: Difference between revisions
Jump to navigation
Jump to search
imported>Jeremy (Importing text file) |
imported>Bob No edit summary |
||
(One intermediate revision by one other user not shown) | |||
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: | ||
::<math> min \left \{{\sigma}_x, \frac {p_{75} - p_{25}} {1.349} \right \} \left ( \frac {0.9} {n} \right ) ^{0.20} </math> | |||
* '''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 31: | ||
* '''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. | ||
** '''fx''' = ? | |||
* '''x''' = vector of points where density was estimated. Will be the same as 'at' 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. | |||
* '''fx''' = ? | ** '''kernel''' = name of kernel 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. | |||
* '''kernel''' = name of kernel used. | |||
===Examples=== | ===Examples=== | ||
<pre> | |||
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,y); | |||
kde = kdensity(x,2,22.4,50); | </pre> | ||
kde = kdensity(x,2,22.4,50,y); | |||
===See Also=== | ===See Also=== | ||
[[plotkd]] | [[plotkd]] |
Latest revision as of 05:38, 10 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);