Removing outliers using standard deviation

Hello everyone,
I have a timetable of 8764*3. The first column corresponds to the date, the second to the hour (which goes from 1 to 24 in double format) and the third is a price. My objective is that, for each hour, I remove the prices that are above (Mean of that hour + 3*SD of the prices of that hour) and any price below (Mean of that hour - 3*SD of the prices of that hour). I know I could use the code:
rmoutliers(A,'mean');
However, this filter would take into account all the hours of the sample. Could someone kindly help me to apply it for each hour?
I attach here the data so you can have a clear view of what I have.
Thank you!

 채택된 답변

Ive J
Ive J 2021년 2월 18일

0 개 추천

groupfilter does the trick
cleanTable = groupfilter(yourTable, 'Hour', @(x)~isoutlier(x, 'mean'), 'Price');

댓글 수: 3

Angelavtc
Angelavtc 2021년 2월 19일
Thank you @Ive J! And is it possible to identify which date observations for each hour were removed?
Yes, outTab (complement of cleanTable) would contain outliers per each hour:
outTab = groupfilter(yourTable, 'Hour', @(x)isoutlier(x, 'mean'), 'Price');
Angelavtc
Angelavtc 2021년 2월 19일
Wonderful, thank you @Ive J!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Financial Toolbox에 대해 자세히 알아보기

질문:

2021년 2월 17일

댓글:

2021년 2월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by