# Interchanging FIR and Decimation operation

Started by April 9, 2005
```Hi all,

I have a yet another decimation question rather a decimation and a FIR
filter question.

I have 64K input samples that are filtered using a 3 tap - 2nd order
FIR filter, say [a1 a2 a3]. After filtering they are decimated by 8.  I
want to reverse this operation such that I decimate first and then
filter it for obvious reasons (why should I compute the taps that
anyways I am going to throw away).

After a long  Goatee-Stroking (as first used by Bhooshan) session, I
came to the conclusion that I will not be able to reverse the operation
(decimate and then FIR instead of FIR and then decimate). I am posting
this to this group in hope of someone proving me wrong or atleast give
me some creative insight to handle this problem.

Thanks.
Tarang

```
```tarangdadia@gmail.com wrote:
> Hi all,
>
> I have a yet another decimation question rather a decimation and a FIR
> filter question.
>
> I have 64K input samples that are filtered using a 3 tap - 2nd order
> FIR filter, say [a1 a2 a3]. After filtering they are decimated by 8.  I
> want to reverse this operation such that I decimate first and then
> filter it for obvious reasons (why should I compute the taps that
> anyways I am going to throw away).
>
> After a long  Goatee-Stroking (as first used by Bhooshan) session, I
> came to the conclusion that I will not be able to reverse the operation
> (decimate and then FIR instead of FIR and then decimate). I am posting
> this to this group in hope of someone proving me wrong or atleast give
> me some creative insight to handle this problem.
>
> Thanks.
> Tarang
>
That is correct, you can't.  I would question whether a length = 3
filter is going to do you much good for decimating data by a factor of 8
-- you would at least need a length = 8 filter and probably more.

You _can_ reduce your workload by only computing the filter for the
decimation times.  This is a large subset of polyphase filtering.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
```
```"tarangdadia@gmail.com" <tarangdadia@gmail.com> writes:

> Hi all,
>
> I have a yet another decimation question rather a decimation and a FIR
> filter question.
>
> I have 64K input samples that are filtered using a 3 tap - 2nd order
> FIR filter, say [a1 a2 a3]. After filtering they are decimated by 8.  I
> want to reverse this operation such that I decimate first and then
> filter it for obvious reasons (why should I compute the taps that
> anyways I am going to throw away).
>
> After a long  Goatee-Stroking (as first used by Bhooshan) session, I
> came to the conclusion that I will not be able to reverse the operation
> (decimate and then FIR instead of FIR and then decimate). I am posting
> this to this group in hope of someone proving me wrong or atleast give
> me some creative insight to handle this problem.
>
> Thanks.
> Tarang

Tarang,

You can't reverse the operations. If you decimate without filtering
and there is signal energy above the decimated Nyquist frequency,
it will irreparably alias into the baseband. Once it's there you
can't subsequently remove it.

However, your intuition was onto something - there is no need to
compute the samples which you are going to throw away anyway. For
example, assume you're decimating by 8 and the filter's output samples
are denoted y[n+0], y[n+1], ..., y[n+7], y[n+8], y[n+9], ... . Since
you're throwing away y[k], 8 !| k, (k is not divisible by 8), you only
need to compute the filter for y[n+0], y[n+1*8], y[n+2*8], etc. In
general, when downsampling by a factor M, this reduces your
computations by a factor of 1/M.
--
Randy Yates
Sony Ericsson Mobile Communications
Research Triangle Park, NC, USA
randy.yates@sonyericsson.com, 919-472-1124
```
```>That is correct, you can't.  I would question whether a length = 3
>filter is going to do you much good for decimating data by a factor of
8
>-- you would at least need a length = 8 filter and probably more.

I forgot to mention one more thing abt the filter. It is not normal
anti-aliasing filter. It is a high pass filter and I have to high pass
64k samples. I still will need a anti-aliasing filter(which will be
more than 8 tap filter in order to take adv of polyphase filtering) to
remove the unncessary out-of-band freq components.

>You _can_ reduce your workload by only computing the filter for the
>decimation times.  This is a large subset of polyphase filtering.

I am aiming to do this but am wondering is there a way in which I can
combine the high pass filter, a anti-aliasing filter (low pass filter)
and decimation together into one operation so that computations are
minimized.

One more thing 64K samples are all one bit long..basically its a binary
bit stream.

Tarang

```
```tarangdadia@gmail.com wrote:

>>That is correct, you can't.  I would question whether a length = 3
>>filter is going to do you much good for decimating data by a factor of
>
> 8
>
>>-- you would at least need a length = 8 filter and probably more.
>
>
>
> I forgot to mention one more thing abt the filter. It is not normal
> anti-aliasing filter. It is a high pass filter and I have to high pass
> 64k samples. I still will need a anti-aliasing filter(which will be
> more than 8 tap filter in order to take adv of polyphase filtering) to
> remove the unncessary out-of-band freq components.
>
>
>>You _can_ reduce your workload by only computing the filter for the
>>decimation times.  This is a large subset of polyphase filtering.
>
>
> I am aiming to do this but am wondering is there a way in which I can
> combine the high pass filter, a anti-aliasing filter (low pass filter)
> and decimation together into one operation so that computations are
> minimized.
>
> One more thing 64K samples are all one bit long..basically its a binary
> bit stream.
>
> Tarang
>
The fact that it's a high-pass, and that you're already dealing with the
anti-aliasing with a polyphase filter makes a huge difference.

You should certainly be able to do some high-pass filtering after the
fact.  It certainly feels like you can combine the high-pass and the
anti-aliasing in the polyphase filtering -- if nothing else you should
be able to convolve the filter from which you are deriving your
polyphase filter coefficients by the high-pass filter coefficients.  At
worst you'll end up with a filter that's a couple of taps longer, but
that shouldn't kill you.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
```
```Randy,

The filter I have in place currently is a high pass filter(hpf). I
understand that I will have to incorporate another anti-aliasing
filter(AAF) before decimating. So now my new problem would be to
optimize this operation

64ksamples-->hpf-->aaf-->decimate.

will have to incorporate all 3 operations into just a single operation.

>However, your intuition was onto something - there is no need to
>compute the samples which you are going to throw away anyway. For
>example, assume you're decimating by 8 and the filter's output samples
>are denoted y[n+0], y[n+1], ..., y[n+7], y[n+8], y[n+9], ... . Since
>you're throwing away y[k], 8 !| k, (k is not divisible by 8), you only
>need to compute the filter for y[n+0], y[n+1*8], y[n+2*8], etc.]]]

I understand that over here we are combining decimation and filtering .
I was wondering if I could combine all 3 operation hpf+aaf+decimate
into just one operation and how would the I get the resultant matrix or
rather what would it be.
Tarang

```
```Thanks Tim.

This does make sense. I will try to simulate the solution in Matlab and
see if I get something rolling here.

Tarang

```
```
>
> Thanks Tim.
>
> This does make sense. I will try to simulate the solution in Matlab and
> see if I get something rolling here.

What you have revealed so far doesn't sound good. I'm have a hard time
picturing what sort of 3 tap hpf you could have that would leave you
with much of anything in the way of amplitude after applying a proper
A-A filter and decimating by 8.

-jim

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
```
```Jim,

HPF that I am using is [1 -2 1]. I need to have that in place because
systems engineer asked me to ;-). It may not be the best HPF but I
believe systems engineers word for it that will be good enough for our
system.

Tarang

jim wrote:
> >
> > Thanks Tim.
> >
> > This does make sense. I will try to simulate the solution in Matlab
and
> > see if I get something rolling here.
>
> What you have revealed so far doesn't sound good. I'm have a hard
time
> picturing what sort of 3 tap hpf you could have that would leave you
> with much of anything in the way of amplitude after applying a proper
> A-A filter and decimating by 8.
>
> -jim
>
> ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet
News==----
> http://www.newsfeeds.com The #1 Newsgroup Service in the World!
120,000+ Newsgroups
> ----= East and West-Coast Server Farms - Total Privacy via Encryption
=----

```
```<tarangdadia@gmail.com> wrote in message
> Randy,
>
> The filter I have in place currently is a high pass filter(hpf). I
> understand that I will have to incorporate another anti-aliasing
> filter(AAF) before decimating. So now my new problem would be to
> optimize this operation
>
> 64ksamples-->hpf-->aaf-->decimate.
>
> will have to incorporate all 3 operations into just a single operation.
>
>
> >However, your intuition was onto something - there is no need to
> >compute the samples which you are going to throw away anyway. For
> >example, assume you're decimating by 8 and the filter's output samples
> >are denoted y[n+0], y[n+1], ..., y[n+7], y[n+8], y[n+9], ... . Since
> >you're throwing away y[k], 8 !| k, (k is not divisible by 8), you only
> >need to compute the filter for y[n+0], y[n+1*8], y[n+2*8], etc.]]]
>
> I understand that over here we are combining decimation and filtering .
> I was wondering if I could combine all 3 operation hpf+aaf+decimate
> into just one operation and how would the I get the resultant matrix or
> rather what would it be.

What is your final band of interest? Your rather sloppy high pass is going
to kill your DC component but also quite a bit of signal all the way to
fs/4. I understand that this has been 'specified' by the system designers,
but it's useful to understand why.
Also, it isn't common to call the low pass filter before the decimation
stage as an 'anti-alias filter' (although that is one of it's primary
purposes). So you might introduce some confusion by using that term in this
context.

Cheers