www.gusucode.com > stats 源码程序 matlab案例代码 > stats/MeasuresOfCentralTendencyExample.m

    %% Measures of Central Tendency
% This example shows how to compute and compare measures of location for
% sample data that contains one oulier.

% Copyright 2015 The MathWorks, Inc.


%%
% Generate sample data that contains one outlier.
x = [ones(1,6),100]

%%
% Compute the geometric mean, harmonic mean, mean, median, and trimmed mean
% for the sample data.
locate = [geomean(x) harmmean(x) mean(x) median(x)... 
          trimmean(x,25)]

%%
% The mean (|mean|) is far from any data value because of
% the influence of the outlier. The geometric mean (|geomean|) and the
% harmonic mean (|harmmean|) are influenced by the outlier, but not as
% significantly. The median (|median|) and trimmed mean (|trimmean|)
% ignore the outlier value and describe the location of the rest of the
% data values.