www.gusucode.com > stats 源码程序 matlab案例代码 > stats/GenerateRandomDataUsingTheTrimmedMeanExample.m
%% Trimmed Mean for Distributions with Outliers % % Copyright 2015 The MathWorks, Inc. %% % Generate random data from the _t_ location-scale distribution, which % tends to have outliers. rng default; % For reproducibility x = trnd(1,40,1); %% % Visualize the distribution using a normal probability plot. probplot(x) %% % Although the distribution is symmetric around zero, there are several % outliers which will affect the mean. The trimmed mean is closer to % zero, which is more representative of the data. mean = mean(x) tmean = trimmean(x,25)