How to remove 5&95 percent outliers by column independently

1 回表示 (過去 30 日間)
Mekala balaji
Mekala balaji 2017 年 9 月 20 日
回答済み: Walter Roberson 2017 年 9 月 20 日
Hi,
I have below data, and want to remove outliers by column independently,
vector:
0.2 2 5
1 4 6
2 0.3 17
2 4 9
40 5 36
3 0.3 54
I use the below function, but it can only be used for column array. How to use for the matrix?
percntiles = prctile(vector,[5 95])
outlierIndexes = vector < percntiles(1) | vector > percntiles(2);
outliers = vector(outlierIndexes)
nonOutliers = vector(~outlierIndexes)
  2 件のコメント
Walter Roberson
Walter Roberson 2017 年 9 月 20 日
Do you want to leave "holes" in the array, or do you want to replace the outliers with 0 or with NaN ?
Mekala balaji
Mekala balaji 2017 年 9 月 20 日
replace outliers with NaN.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 9 月 20 日
Take the per column low percentile which gets you a row of values. Replicate into as many rows as the original. Compare to the original, getting out a logical matrix. Do the same with the high percentile, getting a second logical matrix. Or the two. Now use that as a mask to assign nan to those locations

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by