I implemented the Hampel Filter (see here) for outlier removal, however I noticed in instances when the data in the sliding window is stationary and its standard deviation is very low, the filter will think even the tiniest deviation is an outlier.
For example, if we have sliding window equal to 7 (three values on each adjacent side), with the input series 2, 2, 2, 2.05, 2, 2 ,2
then the Median Absolute Deviation (MAD) = 0 and the filter thinks that the 2.05 is an outlier, independent of how many standard deviations the value should be off by.
Any advice on a workaround?