how to detect and remove outliers?
Show older comments
Hi,
I have a problem detecting outliers in a set of data. Let's say I have two arrays x and y, and y is a quadratic function of x. Some of the values of y do not follow this function. How can I detect them?
I had a look at the `rmoutliers` function, but it doesn't seem to solve this problem since it only deals with normally distributed data.
4 Comments
Matt J
on 31 Dec 2020
but it doesn't seem to solve this problem since it only deals with normally distributed data
Doen't seem that's true to me... There seem to be different method selections some of which don't assume normality
Image Analyst
on 31 Dec 2020
What does "have a look at" mean? Did you actually try it or did you just look at the help? And it can handle data that is not normally distributed. Did you try it and it didn't work? What options did you try? Attach your data if you can't find the proper options to get it to work. Point out the outliers, unless they're really obvious.
Abdelrahman Taha
on 1 Jan 2021
Edited: Abdelrahman Taha
on 1 Jan 2021
Image Analyst
on 1 Jan 2021
x = [-485.35, 144.42, 623.97, 1178.63, 1733.29, 2287.95, 2842.61]
y = [47.85 190.25 164.98 196.69 206.16 186.53 154.81]
plot(x, y, 'b.-', 'LineWidth', 2, 'MarkerSize', 30);
grid on;

No, not obviously. The first, leftmost point could just as well be an outlier as the second point. If your data are all expected to be 170 +/- 50, then the first point is an outlier.
Answers (1)
Cris LaPierre
on 31 Dec 2020
0 votes
You can interactively explore many of the options using the Clean Outlier Data task in a live script.
Another option is to apply your function to X and then take the absolute difference between the result and Y. You can then select a threshhold and use logical indexing to identify any values that deviate more than your threshhold.
2 Comments
Abdelrahman Taha
on 1 Jan 2021
Cris LaPierre
on 1 Jan 2021
You need to have some sort of model to compare against to determine an outlier. Without that, I don't see any way to automate the process.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!