Median Absolute Deviation(MAD,绝对中位差)和3sigma准则剔除粗差方法对比(代码)

根据文献:
Klos A, Bogusz J, Figurski M, Kosek W (2016) On the handling of outliers in the GNSS time series by means of the noise and probability analysis. In: Rizos C, Willis P (eds) IAG 150 Years. Springer International Publishing, pp 657-664

Leys C, Ley C, Klein O, et al (2013) Detecting outliers: Do not use standard deviation around the mean, use absolute deviation around the median. Journal of Experimental Social Psychology 49:764-766. https://doi.org/10.1016/j.jesp.2013.03.013
根据前者文中提出的绝对中位差剔除粗差的方法,编写matlab程序,与3sigma准则剔除粗差的方法进行对比。其中MAD方法程序如下:

function index = MADmethod(data)
% Detecting outliers by Median Absolute Deviation method
% MAD = b*Mi(|xi-Mj(xj)|)
% which b = 1.4826
% And the criterion of the outlier rejection is (deviation can be 3,2.5 or 2):
% M-3*MAD < xi < M+3*MAD
% which M is the median of the origion time series
% by Rong He, 20200126

mad_orig=median(data);
data_sec=[];
for i=1:length(data)
    data_sec(i)=abs(data(i)-mad_orig);
end
b=1.4826;
mad = b*median(data_sec);
%The decision criterion
% index=[]; 
% for j=1:length(data)
%     if ((mad_orig-3*mad)>data(j) | data(j)>(mad_orig+3*mad))
%         index(end+1)=j;
%     end
% end
 index=find((mad_orig-3*mad)>data | data>(mad_orig+3*mad));    

用来实验的序列为模拟某一测站高程方向的时间序列,人为加入60个粗差,效果如下图:
1.MAD方法剔除粗差
Median Absolute Deviation(MAD,绝对中位差)和3sigma准则剔除粗差方法对比(代码)_第1张图片
2.3sigma剔除粗差
Median Absolute Deviation(MAD,绝对中位差)和3sigma准则剔除粗差方法对比(代码)_第2张图片

你可能感兴趣的:(其他笔记)