On 4/14/15 11:11 AM, Cedron wrote:>> >> Why not instead filter with a single, non-causal filter (assuming >> you're >> working with recorded samples)? If you filter forward and reverse, then >> average the two, you're degrading the estimate at the center. Not so >> with a single, non-causal filter. (Or at least "seems" that would be >> true from the hip..)...> > I'll confess I had to look up "non-causal filter". I'll try to answer > briefly as I understand things. If your desire is to have exponential > smoothing, in a non-causal bidirectional manner, doing it in two passes, > forward and reverse will be much more computationally efficient. > Otherwise you would have to multiply your signal by a sliding window > function at each point. I don't see a source of degradation anywhere.two passes means at least two sources of quantization error for every sample. might be okay.> > For the OP's original purpose, a centered sliding rectangular window > moving average would probably work. The advantage of this is you can add > the leading point and subtract the trailing point as the average moves > without having to recalculate the whole sum at each point.there is a generalization of this (the sliding sum or sliding average) called "Truncated IIR filters" (TIIR) which is another method of implementing a kind of FIR filter. you can do this sliding and subtract thing for exponentially decaying impulse response, too. i can send you a pdf doc i wrote that shows you exactly how to set up a TIIR for first or second-order IIR filters and with any arbitrary truncation length. for 1st order: y[n] = p*y[n-1] + A*( x[n] - q*x[n-1] + (p^L)*(q/p-1)*x[n-L] ) p = pole often A=1 and q=1-p, but doesn't have to be.> These methods require additional storage for processing. The big > advantage of the single pass exponential method is that it is quick and > can be done in place.and it's causal and it's IIR. so the DC getting subtracted is based *solely* on the present and past samples. it's likely okay (it's the sole method i have used to block DC) but won't be phase linear (unless you do the filtfilt() thingie).> > In all these methods, the operations can be recast as a matrix > multiplication against a signal vector. In other words, they are all > linear. > > (More shameless self promotion) I will cover the forward and backward > exponential smoothing technique in great detail in a future blog article.it's been done Ced. not that i have written anything about it. i'll send you that pdf regarding TIIR. see if that helps at all. (you'll be able to do perfect filtfilt since a TIIR is, strictly speaking, an FIR. L8r, -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."