Median absolute deviation algorithm