Fast data smoothing using a running average

In the lab, we preprocess eye position data using a running average. We previously used the matlab smooth function, with the ‘moving’ argument. This matlab function implements very generic data smoothing, and is therefore unoptimized and slow. You can download a better running average function from matlab central called runmean. For a window size of 5, it is about 5-fold faster than the generic algorithm. Here’s an example:

eyep = rand(1,1000000);
eyeps1 = smooth(eyep,’moving’,5);

eyeps2 = runmean(eyep,2)’;


The outputs of the two functions are the same except for edges, and on my computer the builtin function takes 0.33 seconds to run while runmean takes 0.07 seconds, so it’s worth the trouble.

One response to “Fast data smoothing using a running average”

  1. Sounds like it’s computing a running mean by way of a Fast Fourier Transform. A running mean is just a convolution after all.

    Nice blog, keep up the good work.

Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s