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.