I'm using a 5-point Triangle Moving Average:


$$S\_j = (Y\_{j-2} + 2Y\_{j-1} + 3Y\_j + 2Y\_{j+1} + Y\_{j+2}) / 9$$


The problem is that I often need to smooth my data more than once, and when I do this too much, it becomes noticeability very slow (and I'm using C++).


Is there a way to optimize this formula?


Like maybe skipping every other data point and then using interpolation in the end, or something clever?


Thanks



Triangular Smoothing Formula Optimization
the "clever" way to improve the efficiency of the moving average filter is to implement it recursively; you will then need only two computations per data point, regardless of the length of the filter.


see page 281 and following of [The Scientist and Engineer's Guide to Digital Signal Processing](http://www.analog.com/static/imported-files/tech_docs/dsp_book_Ch15.pdf).


(the algorithm given there is for a rectangular filter kernel, but the triangular kernel is just the rectangular filter applied twice)


