필터 지우기
필터 지우기

Only abnormally large outlier values are removed, not small ones

조회 수: 5 (최근 30일)
Lina Koronfel
Lina Koronfel 2022년 3월 26일
댓글: Image Analyst 2022년 3월 26일
I used the rmoutlier function to remove outliers from a dataset but it only removed the abnormally large value, not the abnormally small one. Please see figure for reference. Also I used the following line of code:
[Array_wo_outliers(1,:), TF]=rmoutliers(Array_Original(1,:),'mean');
How can I remove both???
Thank you

답변 (1개)

AndresVar
AndresVar 2022년 3월 26일
your data has zeros that make the mean closer to the small peak.
you should ignore the zeros, maybe you can throw them away OR you can try setting them equal to the non-zero data mean.
load('testdatarmoutlier.mat')
ind0 = y==0; % where are the zeros
meannz = mean(y(~ind0)); % mean of non-zero data
figure;
plot(x,y,'rx')
yline(mean(y),'k',Label='mean (close to bottom!)')
yline(meannz,'k',Label='mean ingnore zeros')
y(ind0)=meannz; % make zeros equal to the non-zero data mean
[y2,ind]=rmoutliers(y,'mean');
y(ind0)=0; % restore zeros
figure;
plot(x(~ind),y(~ind),'x')
  댓글 수: 1
Image Analyst
Image Analyst 2022년 3월 26일
or threshold
threshold = 0.5;
y(y < threshold) = []; % Remove all values less than the threshold

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

카테고리

Help CenterFile Exchange에서 Live Scripts and Functions에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by