DSPRelated.com
Forums

Interchanging of filtering and decimation operations

Started by vasindagi April 26, 2008
Mark H wrote:
> On Apr 27, 12:23 pm, Jerry Avins <j...@ieee.org> wrote: >> It needs to be clear that >> one can't decimate first and filter later. >> > Hi Jerry, > > I think there may be times where you can decimate first and filter. If > the significant components of the signal don't alias to be on top of > one another, a person may downsample and then filter. It's essentially > subsampling (or undersampling) a signal. It's important to insure > where the significant components of the signal are before > downsampling, which is a practical problem. > > In regards to John's problem, the aliased components all happen to > fall around 1MHz (neglecting the width of the components) and maybe > the order of the filter needed to filter out the unwanted signals will > be much greater than if the filtering is done first (or even better, > with a polyphase implementation as suggested).
If the original signal contains no significant energy above the new Fs/2, there's no need to filter at all. Is it useful to discuss such special cases? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
DigitalSignal wrote:
> On Apr 27, 10:01 am, "John E. Hadstate" <jh113...@hotmail.com> wrote: >> "DigitalSignal" <digitalsignal...@yahoo.com> wrote in message >> >> news:cda9250a-f6ec-4953-94c9-66dff1f25255@f24g2000prh.googlegroups.com... >> >>> John, Can you try to demodulate the signal at frequency = >>> (1.0103 + >>> 4.3436)/2 = 2.67695 MHz then apply the "skipping >>> decimation"? >> ?? >> >> I don't understand. Can you elaborate? > > John, I should have asked what you intend to do with the frequency > components at one at > 1.0103 MHz, (the signal of interest), one at 2.3230 MHz. and one > at 4.3436 MHz. Do you want to analyze their intensity using FFT?
Clearly, after proper decimation by 3, only the lower two frequencies can be of interest. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Apr 27, 7:40 pm, Jerry Avins <j...@ieee.org> wrote:
> Mark H wrote: > > On Apr 27, 12:23 pm, Jerry Avins <j...@ieee.org> wrote: > > In regards to John's problem, the aliased components all happen to > > fall around 1MHz (neglecting the width of the components) and maybe > > the order of the filter needed to filter out the unwanted signals will > > be much greater than if the filtering is done first (or even better, > > with a polyphase implementation as suggested). > > If the original signal contains no significant energy above the new > Fs/2, there's no need to filter at all. Is it useful to discuss such > special cases? > > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
An example (to show concept) maybe if the signal coming in is sampled at 9Msps with components at 1MHz and 2.5Mhz. Downsampling by 3 will produce a sampling rate of 3Msps and an fs/2 of 1.5Msps. The 2.5MHz signal will be aliased to 0.5MHz (with phase inversion) and the 1MHz signal will remain unchanged at 1MHz. Assuming narrow-band signals, the aliasing in this case doesn't necessarily destroy information. A user can then selectively filter the result to acquire the desired signal. -Mark
Mark H wrote:
> On Apr 27, 7:40 pm, Jerry Avins <j...@ieee.org> wrote: >> Mark H wrote: >>> On Apr 27, 12:23 pm, Jerry Avins <j...@ieee.org> wrote: >>> In regards to John's problem, the aliased components all happen to >>> fall around 1MHz (neglecting the width of the components) and maybe >>> the order of the filter needed to filter out the unwanted signals will >>> be much greater than if the filtering is done first (or even better, >>> with a polyphase implementation as suggested). >> If the original signal contains no significant energy above the new >> Fs/2, there's no need to filter at all. Is it useful to discuss such >> special cases? >> >> Jerry >> -- >> Engineering is the art of making what you want from things you can get. >> &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295; > > > An example (to show concept) maybe if the signal coming in is sampled > at 9Msps with components at 1MHz and 2.5Mhz. Downsampling by 3 will > produce a sampling rate of 3Msps and an fs/2 of 1.5Msps. The 2.5MHz > signal will be aliased to 0.5MHz (with phase inversion) and the 1MHz > signal will remain unchanged at 1MHz. Assuming narrow-band signals, > the aliasing in this case doesn't necessarily destroy information. A > user can then selectively filter the result to acquire the desired > signal.
I can make up other special cases too. would they be germane? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Apr 27, 9:26 pm, Jerry Avins <j...@ieee.org> wrote:
> Mark H wrote: > > On Apr 27, 7:40 pm, Jerry Avins <j...@ieee.org> wrote: > >> Mark H wrote: > >>> On Apr 27, 12:23 pm, Jerry Avins <j...@ieee.org> wrote: > >>> In regards to John's problem, the aliased components all happen to > >>> fall around 1MHz (neglecting the width of the components) and maybe > >>> the order of the filter needed to filter out the unwanted signals will > >>> be much greater than if the filtering is done first (or even better, > >>> with a polyphase implementation as suggested). > >> If the original signal contains no significant energy above the new > >> Fs/2, there's no need to filter at all. Is it useful to discuss such > >> special cases? > > >> Jerry > >> -- > >> Engineering is the art of making what you want from things you can get. > >> &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295; > > > An example (to show concept) maybe if the signal coming in is sampled > > at 9Msps with components at 1MHz and 2.5Mhz. Downsampling by 3 will > > produce a sampling rate of 3Msps and an fs/2 of 1.5Msps. The 2.5MHz > > signal will be aliased to 0.5MHz (with phase inversion) and the 1MHz > > signal will remain unchanged at 1MHz. Assuming narrow-band signals, > > the aliasing in this case doesn't necessarily destroy information. A > > user can then selectively filter the result to acquire the desired > > signal. > > I can make up other special cases too. would they be germane? > > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
There are some communication situations where you can make use of the heterodyning effect of sampling: http://www.sdrforum.org/pages/sdr05/1.4%20Circuits%20and%20Chips2/1.4-03%20Kunisawa.pdf
On Apr 27, 5:13 pm, Jerry Avins <j...@ieee.org> wrote:
> rickman wrote: > > On Apr 27, 1:32 pm, Jerry Avins <j...@ieee.org> wrote: > >> rickman wrote: > > >> ... > > >>> I think I didn't read the OP very well. The question was, can the > >>> filter and decimation steps be interchanged. My answer was, "Yes you > >>> can combine them". No one is saying you don't have to use a filter > >>> and no one is saying that the filter can be *after* the decimation. > >>> But the two can be combined to the advantage of saving processing > >>> steps. If we decimate by 4, your filter is going to produce the > >>> results; Y0, Y1, Y2, Y3, Y4, Y5, Y6,... and you will be decimating to > >>> retain Y0, Y4, Y8,... why bother to calculate the samples that you are > >>> tossing; Y1, Y2, Y3, Y5, Y6, Y7,...? > >> No reason to /if you won't need them later/. > > >>> I am thinking of a FIR filter implementation of course where a > >>> decimation by 4 will save you 3/4 of the calculations in the filter. > >>> But even in an IIR filter, you can save work if you are calculating > >>> the results on the fly. If you are combining 4 steps of a IIR into > >>> one operation, you can save processor work in loading and storing the > >>> intermediate results and loading up the registers for computation. > >> That works. With an IIR it doesn't work because Y[n-1] enters the > >> calculation of y[n]. > > > Jerry, > > > You are usually sharper than that. I didn't say you wouldn't > > calculate each step of an IIR. I said that by combining multiple > > calculations, you can reduce the overhead. It is less work to > > calculate four iterations of an IIR in a loop (and only save the last > > of the four) than it is to return to the same code four times to > > perform four iterations. There is a lot more to a filter than just > > the multiplies and adds. The hard part is actually retrieving and > > saving the data. > > Have you done that? I didn't think it would be possible to use Y[n-3], > Y[n-2], and Y[n-1] in calculating Y[n] without calculating each of them > first. Is there a shortcut?
Actually, this would be pretty simple. But that is not what I am suggesting. Just for completeness, here is how you would do it in one computation. Yn+1= (1-a)*Yn + a*Xn+1 Yn+2 = ((1-a)*((1-a)*Yn + a*Xn+1) + a*Xn+2) Yn+3 = (1-a)*((1-a)*((1-a)*Yn + a*Xn+1) + a*Xn+2) + a*Xn+3 Multiplying through you get Yn+3 = (1-a)**3*Yn + (1-a)**2*a*Xn+1 + (1-a)*a*Xn+2 + aXn+3 I didn't think the math was simpler, but I see that it is. The iterative method uses six multiplies and three adds. The "fast" way uses only four multiplies and three adds. My point is about the overhead that is involved in receiving a sample, loading the values for the computation, storing the result away N times compared to reading three samples, doing the calculation, and saving just the one result you care about. Maybe I am overstating the overhead of processing the IIR one sample at a time. But I expect most any routine is faster if you can process in chunks rather than one sample at a time.
Mark H wrote:
> On Apr 27, 9:26 pm, Jerry Avins <j...@ieee.org> wrote: >> Mark H wrote: >>> On Apr 27, 7:40 pm, Jerry Avins <j...@ieee.org> wrote: >>>> Mark H wrote: >>>>> On Apr 27, 12:23 pm, Jerry Avins <j...@ieee.org> wrote: >>>>> In regards to John's problem, the aliased components all happen to >>>>> fall around 1MHz (neglecting the width of the components) and maybe >>>>> the order of the filter needed to filter out the unwanted signals will >>>>> be much greater than if the filtering is done first (or even better, >>>>> with a polyphase implementation as suggested). >>>> If the original signal contains no significant energy above the new >>>> Fs/2, there's no need to filter at all. Is it useful to discuss such >>>> special cases? >>>> Jerry >>>> -- >>>> Engineering is the art of making what you want from things you can get. >>>> &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295; >>> An example (to show concept) maybe if the signal coming in is sampled >>> at 9Msps with components at 1MHz and 2.5Mhz. Downsampling by 3 will >>> produce a sampling rate of 3Msps and an fs/2 of 1.5Msps. The 2.5MHz >>> signal will be aliased to 0.5MHz (with phase inversion) and the 1MHz >>> signal will remain unchanged at 1MHz. Assuming narrow-band signals, >>> the aliasing in this case doesn't necessarily destroy information. A >>> user can then selectively filter the result to acquire the desired >>> signal. >> I can make up other special cases too. would they be germane? >> >> Jerry >> -- >> Engineering is the art of making what you want from things you can get. >> &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295; > > There are some communication situations where you can make use of the > heterodyning effect of sampling: > http://www.sdrforum.org/pages/sdr05/1.4%20Circuits%20and%20Chips2/1.4-03%20Kunisawa.pdf
Sure. I just don't believe such cases illuminate the general case that seemed to be the basis of the discussion. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
rickman wrote:
> On Apr 27, 5:13 pm, Jerry Avins <j...@ieee.org> wrote: >> rickman wrote: >>> On Apr 27, 1:32 pm, Jerry Avins <j...@ieee.org> wrote: >>>> rickman wrote: >>>> ... >>>>> I think I didn't read the OP very well. The question was, can the >>>>> filter and decimation steps be interchanged. My answer was, "Yes you >>>>> can combine them". No one is saying you don't have to use a filter >>>>> and no one is saying that the filter can be *after* the decimation. >>>>> But the two can be combined to the advantage of saving processing >>>>> steps. If we decimate by 4, your filter is going to produce the >>>>> results; Y0, Y1, Y2, Y3, Y4, Y5, Y6,... and you will be decimating to >>>>> retain Y0, Y4, Y8,... why bother to calculate the samples that you are >>>>> tossing; Y1, Y2, Y3, Y5, Y6, Y7,...? >>>> No reason to /if you won't need them later/. >>>>> I am thinking of a FIR filter implementation of course where a >>>>> decimation by 4 will save you 3/4 of the calculations in the filter. >>>>> But even in an IIR filter, you can save work if you are calculating >>>>> the results on the fly. If you are combining 4 steps of a IIR into >>>>> one operation, you can save processor work in loading and storing the >>>>> intermediate results and loading up the registers for computation. >>>> That works. With an IIR it doesn't work because Y[n-1] enters the >>>> calculation of y[n]. >>> Jerry, >>> You are usually sharper than that. I didn't say you wouldn't >>> calculate each step of an IIR. I said that by combining multiple >>> calculations, you can reduce the overhead. It is less work to >>> calculate four iterations of an IIR in a loop (and only save the last >>> of the four) than it is to return to the same code four times to >>> perform four iterations. There is a lot more to a filter than just >>> the multiplies and adds. The hard part is actually retrieving and >>> saving the data. >> Have you done that? I didn't think it would be possible to use Y[n-3], >> Y[n-2], and Y[n-1] in calculating Y[n] without calculating each of them >> first. Is there a shortcut? > > Actually, this would be pretty simple. But that is not what I am > suggesting. Just for completeness, here is how you would do it in one > computation. > > Yn+1= (1-a)*Yn + a*Xn+1 > > Yn+2 = ((1-a)*((1-a)*Yn + a*Xn+1) + a*Xn+2) > > Yn+3 = (1-a)*((1-a)*((1-a)*Yn + a*Xn+1) + a*Xn+2) + a*Xn+3 > > Multiplying through you get > > Yn+3 = (1-a)**3*Yn + (1-a)**2*a*Xn+1 + (1-a)*a*Xn+2 + aXn+3 > > I didn't think the math was simpler, but I see that it is. The > iterative method uses six multiplies and three adds. The "fast" way > uses only four multiplies and three adds. > > My point is about the overhead that is involved in receiving a sample, > loading the values for the computation, storing the result away N > times compared to reading three samples, doing the calculation, and > saving just the one result you care about. > > Maybe I am overstating the overhead of processing the IIR one sample > at a time. But I expect most any routine is faster if you can process > in chunks rather than one sample at a time.
Neat! How does it work when the filter needs more history than the number of discarded samples? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;

Jerry Avins wrote:

> > Sure. I just don't believe such cases illuminate the general case that > seemed to be the basis of the discussion. > >
I thought he was talking about the general case. The rule for downsampling is simply this - If downsampling without filtering results in aliases that land on top of the signal of interest you can't separate out that signal of interest after decimation. However there are lots of common cases where decimation does not produce aliases that land on the signal of interest. In those cases you can filter after you have reduced the sample rate by discarding samples. For instance: If you have a signal sampled at 100 KHz and you know the frequency content all exists below 30 KHz. You can downsample by 2 by discarding every other sample. This will produce aliases in the range of 20-25 KHz at the new sample rate. That is the new signal will be corrupted by aliasing in that frequency range only. Now if the signal of interest is in the range 0-15 KHz it will be no problem at all to do the filtering after the decimation. Another way to look at the above example is you don't need to do all the filtering before decimation (i.e. in the above example the reason you knew the content was limited to 30K was due to a filter) -jim ----== Posted via Pronews.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.pronews.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= - Total Privacy via Encryption =---