![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189462/image.jpeg)
Hello, currently I'm working on outlier detection techniques. Can I detect outliers in multivariate datasets with three-sigma rule? If yes, then how?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
m=mean(meas)
m =
5.8433 3.0573 3.7580 1.1993
>> d=std(m)
d =
1.9185
>> d=3*std(m)
d =
5.7555
0 commentaires
Réponses (1)
Adam Danz
le 24 Juin 2018
Are you asking how to do this programmatically or conceptually? You want to detect all values that are greater than three standard deviations from the mean.
Here's a demo with fake data to work through conceptually. In the plot, data outside of 3sd along the y axis are circled.
%fake data
rng(180)
d = normrnd(166,42,1,5000);
m = mean(d);
sd = std(d);
outliers = false(size(d));
outliers(d < m-sd*3) = true;
outliers(d > m+sd*3) = true;
figure
t = 1:length(d);
plot(t, d, 'b.')
hold on
plot(t(outliers), d(outliers), 'ro')
rh = refline(0,m);
set(rh, 'color', 'm')
rh2 = refline(0,m+sd*3);
rh3 = refline(0,m-sd*3);
set([rh2,rh3], 'color', 'm', 'linestyle', '--')
legend('data', 'outliers', 'mean', '3rd sd')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189462/image.jpeg)
1 commentaire
Image Analyst
le 24 Juin 2018
This:
outliers = false(size(d));
outliers(d < m-sd*3) = true;
outliers(d > m+sd*3) = true;
could be simplified to this:
outliers = abs(d - m) > sd * 3;
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!