I didn't see any posts with this so:
An Alpha beta filter can be used to make a running average.
Inside a loop.
...
EstimateCurrent = AlphaEstimateLast + Betameasured_value
EstimateLast = EstimateCurrent
...
where Alpha is defined as a number between 0 and 1 and Beta = Alpha -1.
An Alpha near 1 has a long time constant (Beta will be small, using less sample value).
If you start with a good number, and use an Alpha close to 1, the EstimateCurrent will not be perturbed much by the bad measurements.
Then test to see if new measured value is within a certain "acceptable region" of the EstimateCurrent.
Hope that's helpful.