trimmean - Mean excluding outliers

Syntax

m = trimmean(X,percent)
trimmean(X,percent,dim)

Description

m = trimmean(X,percent) calculates the mean of a sample X excluding the highest and lowest (percent/2)% of the observations. For a vector input, m is the trimmed mean of X. For a matrix input, m is a row vector containing the trimmed mean of each column of X. For N-dimensional arrays, trimmean operates along the first nonsingleton dimension of X. percent is a scalar between 0 and 100.

trimmean(X,percent,dim) takes the trimmed mean along dimension dim of X.

Remarks

The trimmed mean is a robust estimate of the location of a sample. If there are outliers in the data, the trimmed mean is a more representative estimate of the center of the body of the data than the mean. However, if the data is all from the same probability distribution, then the trimmed mean is less efficient than the sample mean as an estimator of the location of the data.

Examples

This example shows a Monte Carlo simulation of the efficiency of the 10% trimmed mean relative to the sample mean for normal data.

x = normrnd(0,1,100,100);
m = mean(x);
trim = trimmean(x,10);
sm = std(m);
strim = std(trim);
efficiency = (sm/strim).^2
efficiency =
  0.9702

See Also

mean, median, geomean, harmmean

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS