Forums

Average the averages

Started by sorenbirk October 9, 2006
I am making an application where several inputs has to be filtered. The
filtering is a simple moving average filtering with a variable filter
length. The problem is what happens when I connect these moving average
filters in cascade? I know that I will get some aliasing, but how big is
the aliasing problem? The scenario is as follows: 

The fastest sampling rate of the system is 100 Hz. I connect a number of
filters in cascade, i.e. is use the output of the first filter as input to
the next. Between the filters I downsample the signal with factor M (M = fs
x k, where k is an integer larger than 1). I know that one are suppose to
use anti aliasing filters when downsampling to avoid aliasing, but if I
use these  AA filters, the beatiful simplicity of the system is lost. So I
am willing to accept some aliasing, but I cannot figure out how much
aliasing I will get. To make my problem clearer, here is an example: Two
filters connected in cascade with downsampling in between. Both filters
are 2 point moving average filters. The input to the first filter is
sampled at 100 Hz. The averaged output of the first filter is downsampled
by a factor 2, to 50 Hz. This signal is used as input to the next filter.

Input to filter 1: x1, x2, x3, x4, x5, x6, x7, ...

Output of the first filter: (x1+x2)/2, (x2+x3)/2, (x3+x4)/2, (x4+x5)/2,
...

after downsampling by 2 (reomve every second sample): (x1+x2)/2,
(x3+x4)/2, (x5+x6)/2, ...

which is input to the second filter.

Output of the second filter:(x1+x2)/2 + (x3+x4)/2  (x5+x6)/2 + (x7+x8)/2
			    ---------------------, ---------------------,.. 
				       2		       2

which eaquals: x1/4 + x2/4 + x3/4 + x4/4, x5/4 + x6/4 + x7/4 + x8/4,
.....

It seems to me as the two 2-point MA filters in cascade with downsampling
inbetween results in a 4-point MA filter. So to sum up: How big a problem
is the aliasing?



The frequency response of your "filter" should be a si function, as you 
use a rect time window. Correct?

Best regards,

Andre

sorenbirk wrote:
> I am making an application where several inputs has to be filtered. The > filtering is a simple moving average filtering with a variable filter > length. The problem is what happens when I connect these moving average > filters in cascade? I know that I will get some aliasing, but how big is > the aliasing problem? The scenario is as follows: > > The fastest sampling rate of the system is 100 Hz. I connect a number of > filters in cascade, i.e. is use the output of the first filter as input to > the next. Between the filters I downsample the signal with factor M (M = fs > x k, where k is an integer larger than 1). I know that one are suppose to > use anti aliasing filters when downsampling to avoid aliasing, but if I > use these AA filters, the beatiful simplicity of the system is lost. So I > am willing to accept some aliasing, but I cannot figure out how much > aliasing I will get. To make my problem clearer, here is an example: Two > filters connected in cascade with downsampling in between. Both filters > are 2 point moving average filters. The input to the first filter is > sampled at 100 Hz. The averaged output of the first filter is downsampled > by a factor 2, to 50 Hz. This signal is used as input to the next filter. > > Input to filter 1: x1, x2, x3, x4, x5, x6, x7, ... > > Output of the first filter: (x1+x2)/2, (x2+x3)/2, (x3+x4)/2, (x4+x5)/2, > .. > > after downsampling by 2 (reomve every second sample): (x1+x2)/2, > (x3+x4)/2, (x5+x6)/2, ... > > which is input to the second filter. > > Output of the second filter:(x1+x2)/2 + (x3+x4)/2 (x5+x6)/2 + (x7+x8)/2 > ---------------------, ---------------------,.. > 2 2 > > which eaquals: x1/4 + x2/4 + x3/4 + x4/4, x5/4 + x6/4 + x7/4 + x8/4, > .... > > It seems to me as the two 2-point MA filters in cascade with downsampling > inbetween results in a 4-point MA filter. So to sum up: How big a problem > is the aliasing? > > >
-- For emailing me, please exchange abuse by a . l o d w i g
>I am making an application where several inputs has to be filtered. The >filtering is a simple moving average filtering with a variable filter >length. The problem is what happens when I connect these moving average >filters in cascade? I know that I will get some aliasing, but how big is >the aliasing problem? The scenario is as follows: > >The fastest sampling rate of the system is 100 Hz. I connect a number of >filters in cascade, i.e. is use the output of the first filter as input
to
>the next. Between the filters I downsample the signal with factor M (M =
fs
>x k, where k is an integer larger than 1). I know that one are suppose
to
>use anti aliasing filters when downsampling to avoid aliasing, but if I >use these AA filters, the beatiful simplicity of the system is lost. So
I
>am willing to accept some aliasing, but I cannot figure out how much >aliasing I will get. To make my problem clearer, here is an example: Two >filters connected in cascade with downsampling in between. Both filters >are 2 point moving average filters. The input to the first filter is >sampled at 100 Hz. The averaged output of the first filter is
downsampled
>by a factor 2, to 50 Hz. This signal is used as input to the next
filter.
> >Input to filter 1: x1, x2, x3, x4, x5, x6, x7, ... > >Output of the first filter: (x1+x2)/2, (x2+x3)/2, (x3+x4)/2, (x4+x5)/2, >... > >after downsampling by 2 (reomve every second sample): (x1+x2)/2, >(x3+x4)/2, (x5+x6)/2, ... > >which is input to the second filter. > >Output of the second filter:(x1+x2)/2 + (x3+x4)/2 (x5+x6)/2 + (x7+x8)/2 > ---------------------, ---------------------,.. > 2 2 > >which eaquals: x1/4 + x2/4 + x3/4 + x4/4, x5/4 + x6/4 + x7/4 + x8/4, >..... > >It seems to me as the two 2-point MA filters in cascade with
downsampling
>inbetween results in a 4-point MA filter. So to sum up: How big a
problem
>is the aliasing? > > > >
Sorry about the layout. The output of the second filter is (x1+x2)/2 + (x3+x4)/2 (x5+x6)/2 + (x7+x8)/2 ---------------------, ---------------------,... 2 2
Hi Andre

Yes, that is correct.


>The frequency response of your "filter" should be a si function, as you >use a rect time window. Correct? > >Best regards, > >Andre > >sorenbirk wrote: >> I am making an application where several inputs has to be filtered.
The
>> filtering is a simple moving average filtering with a variable filter >> length. The problem is what happens when I connect these moving
average
>> filters in cascade? I know that I will get some aliasing, but how big
is
>> the aliasing problem? The scenario is as follows: >> >> The fastest sampling rate of the system is 100 Hz. I connect a number
of
>> filters in cascade, i.e. is use the output of the first filter as input
to
>> the next. Between the filters I downsample the signal with factor M (M
= fs
>> x k, where k is an integer larger than 1). I know that one are suppose
to
>> use anti aliasing filters when downsampling to avoid aliasing, but if
I
>> use these AA filters, the beatiful simplicity of the system is lost.
So I
>> am willing to accept some aliasing, but I cannot figure out how much >> aliasing I will get. To make my problem clearer, here is an example:
Two
>> filters connected in cascade with downsampling in between. Both
filters
>> are 2 point moving average filters. The input to the first filter is >> sampled at 100 Hz. The averaged output of the first filter is
downsampled
>> by a factor 2, to 50 Hz. This signal is used as input to the next
filter.
>> >> Input to filter 1: x1, x2, x3, x4, x5, x6, x7, ... >> >> Output of the first filter: (x1+x2)/2, (x2+x3)/2, (x3+x4)/2,
(x4+x5)/2,
>> .. >> >> after downsampling by 2 (reomve every second sample): (x1+x2)/2, >> (x3+x4)/2, (x5+x6)/2, ... >> >> which is input to the second filter. >> >> Output of the second filter:(x1+x2)/2 + (x3+x4)/2 (x5+x6)/2 +
(x7+x8)/2
>> ---------------------, ---------------------,.. >> 2 2 >> >> which eaquals: x1/4 + x2/4 + x3/4 + x4/4, x5/4 + x6/4 + x7/4 + x8/4, >> .... >> >> It seems to me as the two 2-point MA filters in cascade with
downsampling
>> inbetween results in a 4-point MA filter. So to sum up: How big a
problem
>> is the aliasing? >> >> >> > > >-- > >For emailing me, please exchange abuse by >a . l o d w i g > >