Median Filters

  • Synopsis: A smoothing technique that can give better results than moving averages for some types of data (output is always an actual datum; captures sudden changes in the data better)

  • Assumptions: Disturbances in signal are short compared to filter length

What is useful about median filters for our purposes here is that they are good at rejecting short disruptions to a signal, whilst doing a reasonable job of preserving the shape of the 'good' bit. For instance, here's a sine wave that's been disrupted by a series of spikes (blue line), and the result of running a median filter over this. We would call these spikes outliers.

Median Filter De-Spiking

A median filter works in a very different way to more common audio filters (low-pass, high-pass etc.). We slide a window across our data, and are interested in the median value in the window: if we sorted the sample values in the window by their value, then the median is the sample value that ends up in the middle of this sorted list. We can see the process at work below, applied to the same case as above. The shaded area is the window, and the horizontal bar shows us where the median is at each point.