manipulating matrix for outlier detection

%ids are the point numbers, L is the measurement which need to be checked for outlier.
ids=[1;2;3;4;5;6;7;8;9;10];
L=[0.16;0.2;0.18;0.4;0.14;0.15;0.11;0.17;0.15;0.18]; %measurement
% To perform outlier detection for 0.16;
L_1=[0.2;0.18;0.4;0.14;0.15;0.11;0.17;0.15;0.18]; %without first row of L (0.16)
L_ort_1=mean(L_1);
for i=1:9 % n=9
V(i)=L_1(i)-L_ort_1;
end
V=V(:);
S=sqrt((V'*V)/7);
d=abs(L_ort_1-0.16) %0.16 is subjected to outlier detection
Sd=((S^2)/8)+S^2;
t_1=d/Sd;
t_statistics_1=tinv(0.995,7);
if t_statistics_1 > t_1
% there is no outlier for 0.16 (id=1) go on to check second number (0.20).
%L_2=[0.16;0.18;0.4;0.14;0.15;0.11;0.17;0.15;0.18] %without 0.20 (second number)
% do the same things to L2 for detection of 0.20....................
if t_statistics_1 < t_1
% there is outlier for 0.16, save its id (1) and go on to check second number (0.20)
end
end
I need to write this kind of loop for this outlier detection for each row of L.
Thanks in advance.

 채택된 답변

Image Analyst
Image Analyst 2015년 1월 10일

1 개 추천

So, what's stopping you?
If you want an outlier detection method developed by the Mathworks, see this by the amazing Brett Shoelson: http://www.mathworks.com/matlabcentral/fileexchange/3961-deleteoutliers
You might also look at Median Absolute Deviation which is a more robust method than looking at the z score, which can be influenced by the outlier itself which you want to get rid of ( not a good thing obviously).

댓글 수: 1

Greg Heath
Greg Heath 2015년 1월 13일
Correct. However, the sensitivity of the zscore method can be mitigated via iterated removal or modification, plots and human intervention.
Greg

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Greg Heath
Greg Heath 2015년 1월 10일

1 개 추천

The best way to detect outliers
1. Standardize the data to zero-mean/unit variance
2. Plot
3. Find outliers where abs(x) > mean + alpha*sigma
where alpha is a user determined parameter
Hope this helps.
Thank you for formally accepting my answer
Greg

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2015년 1월 10일

댓글:

2015년 1월 13일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by