hampel
Remove outliers using a Hampel filter.
Syntax
h = hampel(x)
h = hampel(x,k)
h = hampel(x,k,sigma)
h = hampel(x,k,sigma,'usenan')
Inputs
- x
- The data sample. For matrix inputs the filter is applied to the first non-singleton dimension.
- k
- The number of samples used in the moving window analysis. (default: 6)
- sigma
- The number of standard deviations from the moving median used to identify outliers. (default: 3)
- 'usenan'
- Use this flag to replace outliers by NaN values. Otherwise, outliers are replaced by moving median values.
Outputs
- h
- The hampel filtered results.
Example
x = [1,2,3,4,8,-4,9,-3,-2,-1,9,3,4,2,0];
y = hampel(x,[],[],'usenan')
y = [Matrix] 1 x 15
1 2 3 4 8 -4 9 -3 -2 -1 NaN 3 4 2 0
Comments
The moving standard deviation is approximated from the moving median absolute deviation from the median, assuming normally distributed deviations.