Replace extreme outliers in dataset
2 views (last 30 days)
Show older comments
Vlatko Milic on 9 Apr 2019
Commented: Drewsky3 on 11 Dec 2019
I want to replace "extreme" outliers in a data set. The data set varies quite a lot in terms of values, i.e. the maximum values are 50 times larger than the minimum values. However, in circa 0.05 % of the data points there are obvious mistakes depending on measurements errors. These values are at least 10 times larger than the maximum values in the data set. My question is therefore:
- How can I replace the wrong value with the average of the value to the left and to the right of the wrong one? I know about the function "filloutliers" but the function finds values more than three local standard deviations away from the local mean. I need 5 or 6 means because of the large spread in data.
Have you considered hacking the source of filloutliers.m? If it is only a matter of scaling, then it is probably a simple one line change.
Edited: David Wilson on 10 Apr 2019
Not difficult to hack, but slightly more complex to hack correctly. Just copy (and rename) the function into your work directory, and
>> which filloutliers
>> !copy "C:\Program Files\MATLAB\R2018b\toolbox\matlab\datafun\filloutliers.m" myFillOutliers.m
1 file(s) copied.
>> edit myFilloutliers
I'd start hacking on about line 335.
But there seems to be a problem calling the (invisible) function locateoutliers. You might have better luck carefully hacking the original function.
Drewsky3 on 11 Dec 2019
Sooooo. . . . if you had an old lisence that never updated, and then someone had a new lisence, could you copy the new function library to the older version's program file?
Find more on Get Started with MATLAB 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!