Replace extreme outliers in dataset

4 ビュー (過去 30 日間)
Vlatko Milic
Vlatko Milic 2019 年 4 月 9 日
コメント済み: Drewsky3 2019 年 12 月 11 日
Hi,
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.
Kind regards!
  2 件のコメント
dpb
dpb 2019 年 4 月 9 日
Post a typical dataset or two...
Vlatko Milic
Vlatko Milic 2019 年 4 月 10 日
Hi, see attached file for two examples. In the 1st example I know there are some outliers and I suspect now that the original filloutliers that includes three local standard deviations away from the local mean might work. Do you have any advice maybe? :)
Thank you!

サインインしてコメントする。

回答 (2 件)

David Wilson
David Wilson 2019 年 4 月 10 日
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.
  1 件のコメント
Vlatko Milic
Vlatko Milic 2019 年 4 月 10 日
Hi,
I did not know this was possible in Matlab. Is it difficult to hack the function? Any help is much appreciated :)
Thank you!

サインインしてコメントする。


David Wilson
David Wilson 2019 年 4 月 10 日
編集済み: David Wilson 2019 年 4 月 10 日
Not difficult to hack, but slightly more complex to hack correctly. Just copy (and rename) the function into your work directory, and
>> which filloutliers
C:\Program Files\MATLAB\R2018b\toolbox\matlab\datafun\filloutliers.m
>> !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.
  3 件のコメント
dpb
dpb 2019 年 4 月 10 日
I wouldn't recommend that route; bring the private functions need along as well so don't end up with base routine not doing what it does for other uses.
Plus, if do that and every install either a new release or a patch to the current, everything you've done will get overwritten and you'll have to do it all over again.
I used to do some things like that with a copule of particular functions that I didn't like their behavior but finally came to realize it was not the way to get the desired functionality for the longer term...
Drewsky3
Drewsky3 2019 年 12 月 11 日
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?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWrite Unit Tests についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by