DSPRelated.com
Forums

Computing Moving Average filter's coefficients

Started by Flashman January 5, 2009
On Jan 5, 4:28&#4294967295;am, "Flashman" <ya...@doar.afeka.ac.il> wrote:
> Hello everyone, > > first, please excuse me for spelling or grammer mistakes. > > I was asked to estimate ,with Matlab, an MA filter's (FIR filter) > coefficients only from 10,000 output data samples (y(t)) which I've been > given on a DAT file. > > The filter is a 3rd order filter, so i need to compute b0, b1, b2, b3 > coefficients. The input signal x(t) is a white gaussian noise: &#4294967295; > x= rand(1,10000) > > now, if I had b0-b3 and had to compute the output y(t), Matlab's filter > function can solve it easily. > but I don't have a clue how can I estimate b0-b3 from y(t). > > can someone please help? > > Thanks in advance, > Flashman.
Perhaps what you really want to do is smoothing instead of filtering. Smoothing is done after the fact and an use future data points as well as past data points. See this http://en.wikipedia.org/wiki/Savitzky%E2%80%93Golay_smoothing_filter One can calculate coefficients for filter by specifying the order of filter and how many points ahead and behind you are smoothing. It is possible that all the points can be in the past in which case the SG smoothing is just another type of FIR filter. It is also possible to calculate a smooth derivative at each point. Peter Nachtwey
On Jan 5, 4:28 am, "Flashman" <ya...@doar.afeka.ac.il> wrote:

> Hello everyone, > > first, please excuse me for spelling or grammer mistakes.
> I was asked to estimate ,with Matlab, an MA filter's (FIR filter) > coefficients only from 10,000 output data samples (y(t)) which I've been > given on a DAT file.
This section seems to have triggered the comp.dsp language lawyers. Perhaps if you had said: " I was asked to estimate ,with Matlab, an MA model's coefficients as defined by: Spectrum analysis&#4294967295;A modern perspective Kay, S.M. Marple, S.L., Jr. Proceedings of the IEEE; Nov. 1981 On page(s): 1380- 1419, specifically section II.F on p1398 only from 10,000 output data samples (y(t)) which I've been given on a DAT file." you would have had less trouble. Perhaps not. Have you considered the approaches suggested or referenced there?
> > The filter is a 3rd order filter, so i need to compute b0, b1, b2, b3 > coefficients. The input signal x(t) is a white gaussian noise: > x= rand(1,10000) > > now, if I had b0-b3 and had to compute the output y(t), Matlab's filter > function can solve it easily. > but I don't have a clue how can I estimate b0-b3 from y(t). > > can someone please help? > > Thanks in advance, > Flashman.
The rest of your question seems correct about determining the values of an MA model's coefficients, if you can avoid the language law here. Perhaps in sci.math.num-analysis you could find an audience more accepting of established nomenclature of traditional DSP concepts. Dale B. Dalrymple
On Mon, 12 Jan 2009 12:39:23 -0800, Rick Lyons
<R.Lyons@_BOGUS_ieee.org> wrote:

>On Mon, 5 Jan 2009 05:44:08 -0800 (PST), Oli Charlesworth ><catch@olifilth.co.uk> wrote: > >>On Jan 5, 12:57&#4294967295;pm, jim <".sjedgingN0sp"@m...@mwt.net> wrote: >>> Flashman wrote: >>> >>> > Hello everyone, >>> >>> > first, please excuse me for spelling or grammer mistakes. >>> >>> > I was asked to estimate ,with Matlab, an MA filter's (FIR filter) >>> > coefficients only from 10,000 output data samples (y(t)) which I've been >>> > given on a DAT file. >>> >>> > The filter is a 3rd order filter, so i need to compute b0, b1, b2, b3 >>> > coefficients. The input signal x(t) is a white gaussian noise: >>> > x= rand(1,10000) >>> >>> > now, if I had b0-b3 and had to compute the output y(t), Matlab's filter >>> > function can solve it easily. >>> > but I don't have a clue how can I estimate b0-b3 from y(t). >>> >>> Maybe I don't understand the question. If it is a moving average filter with 4 >>> coefficients, it looks like a[1 1 1 1] where a is some constant factor of gain. >>> If you are asking how to determine what a is by looking only at the output - I >>> don't think you can. >> >>In statistics, the term "moving average" is much more general. See >>e.g. http://en.wikipedia.org/wiki/Moving_average_model or >>http://en.wikipedia.org/wiki/Autoregressive_moving_average_model. > >Hi Oli, > Ha ha. Language language language. > >When I first read the OP's words: "MA filter's" I >assumed he meant coefficients all having the same >value. Then when he wrote: "b0-b3", I wasn't so >sure. > >I don't consider a convolutional FIR filter having >different-valued coefficients as a "moving-average >filter", because such filters do not compute >moving averages.
It does, it's just a weighted average. A boxcar is just a special case of an MA filter where the weights are all equal. Since people tend to think of "averages" or "means" in the strict statistical population analysis sense, it's natural to restrict the term to just the boxcar application. Personally I think any FIR is an MA filter, it's just the difference of whether the weighting is uniform or not to match the more traditional sense of averaging with a boxcar filter.
>The OP should have been a little more clear. >But no super-big deal, such confusion happens all >the time here. > >See Ya', >[-Rick-]
So much of the terminology is overloaded or applied slightly differently in different applications that it seems like it's always a good idea to be careful about defining or clarifying things early on in a discussion. Eric Jacobsen Minister of Algorithms Abineau Communications http://www.ericjacobsen.org Blog: http://www.dsprelated.com/blogs-1/hf/Eric_Jacobsen.php
On Jan 12, 11:11&#4294967295;pm, dbd <d...@ieee.org> wrote:
> On Jan 5, 4:28 am, "Flashman" <ya...@doar.afeka.ac.il> wrote: > > > Hello everyone, > > > first, please excuse me for spelling or grammer mistakes. > > I was asked to estimate ,with Matlab, an MA filter's (FIR filter) > > coefficients only from 10,000 output data samples (y(t)) which I've been > > given on a DAT file. > > This section seems to have triggered the comp.dsp language lawyers. > > Perhaps if you had said: > " I was asked to estimate ,with Matlab, an MA model's coefficients > as defined by: > > Spectrum analysis&#4294967295;A modern perspective > Kay, S.M. &#4294967295; Marple, S.L., Jr. > Proceedings of the IEEE; Nov. 1981 > On page(s): 1380- 1419, > specifically section II.F on p1398 > > only from 10,000 output data samples (y(t)) which I've been given on a > DAT file." you would have had less trouble. > > Perhaps not. > > Have you considered the approaches suggested or referenced there? > > > > > The filter is a 3rd order filter, so i need to compute b0, b1, b2, b3 > > coefficients. The input signal x(t) is a white gaussian noise: > > x= rand(1,10000) > > > now, if I had b0-b3 and had to compute the output y(t), Matlab's filter > > function can solve it easily. > > but I don't have a clue how can I estimate b0-b3 from y(t). > > > can someone please help? > > > Thanks in advance, > > Flashman. > > The rest of your question seems correct about determining the values > of an MA model's coefficients, if you can avoid the language law here. > > Perhaps in sci.math.num-analysis you could find an audience more > accepting of established nomenclature of traditional DSP concepts. > > Dale B. Dalrymple
All he need do is type HELP INVFREQZ in Matlab, and all will be explained. Maurice Givens
On Tue, 13 Jan 2009 13:21:24 -0700, Eric Jacobsen
<eric.jacobsen@ieee.org> wrote:

>On Mon, 12 Jan 2009 12:39:23 -0800, Rick Lyons ><R.Lyons@_BOGUS_ieee.org> wrote: > >>On Mon, 5 Jan 2009 05:44:08 -0800 (PST), Oli Charlesworth >><catch@olifilth.co.uk> wrote: >> >>>On Jan 5, 12:57&#4294967295;pm, jim <".sjedgingN0sp"@m...@mwt.net> wrote: >>>> Flashman wrote: >>>> >>>> > Hello everyone, >>>> >>>> > first, please excuse me for spelling or grammer mistakes. >>>> >>>> > I was asked to estimate ,with Matlab, an MA filter's (FIR filter) >>>> > coefficients only from 10,000 output data samples (y(t)) which I've been >>>> > given on a DAT file. >>>> >>>> > The filter is a 3rd order filter, so i need to compute b0, b1, b2, b3 >>>> > coefficients. The input signal x(t) is a white gaussian noise: >>>> > x= rand(1,10000) >>>> >>>> > now, if I had b0-b3 and had to compute the output y(t), Matlab's filter >>>> > function can solve it easily. >>>> > but I don't have a clue how can I estimate b0-b3 from y(t). >>>> >>>> Maybe I don't understand the question. If it is a moving average filter with 4 >>>> coefficients, it looks like a[1 1 1 1] where a is some constant factor of gain. >>>> If you are asking how to determine what a is by looking only at the output - I >>>> don't think you can. >>> >>>In statistics, the term "moving average" is much more general. See >>>e.g. http://en.wikipedia.org/wiki/Moving_average_model or >>>http://en.wikipedia.org/wiki/Autoregressive_moving_average_model. >> >>Hi Oli, >> Ha ha. Language language language. >> >>When I first read the OP's words: "MA filter's" I >>assumed he meant coefficients all having the same >>value. Then when he wrote: "b0-b3", I wasn't so >>sure. >> >>I don't consider a convolutional FIR filter having >>different-valued coefficients as a "moving-average >>filter", because such filters do not compute >>moving averages. > >It does, it's just a weighted average. A boxcar is just a special >case of an MA filter where the weights are all equal. Since people >tend to think of "averages" or "means" in the strict statistical >population analysis sense, it's natural to restrict the term to just >the boxcar application. Personally I think any FIR is an MA filter, >it's just the difference of whether the weighting is uniform or not to >match the more traditional sense of averaging with a boxcar filter. >>The OP should have been a little more clear. >>But no super-big deal, such confusion happens all >>the time here. >> >>See Ya', >>[-Rick-] > >So much of the terminology is overloaded or applied slightly >differently in different applications that it seems like it's always a >good idea to be careful about defining or clarifying things early on >in a discussion. > >Eric Jacobsen
Hi Eric, You're not alone in your opinion. Our DSP guru pal Maurice Givens (do you remember Maurice from the COMP.DSP Conference at Danville Signal Proc. Inc. a few years ago?) just sent me a private E-mail telling me that's it's definitely appropriate to refer to any tapped-delay line FIR filter as a "moving average" filter. Maurice reminded me that an IIR filter having both feed-forward and feedback taps is called an "auto-regressive moving average" (ARMA) process. I've seen the "ARMA" acronym many times before but never gave the terminology much thought. I'll have to think some more about how a, for example, half-band FIR filter can legitimately be called a "moving average" filter. In any case Eric, when you and Maurice both make an effort to "straighten me out", I'd better pay attention. So OK, ... from now on when someone refers to an FIR filter as a "moving average" filter, I'll not assume the filter coefficients are all equal. See Ya', [-Rick-]
On Wed, 14 Jan 2009 03:30:45 -0800, Rick Lyons
<R.Lyons@_BOGUS_ieee.org> wrote:

>On Tue, 13 Jan 2009 13:21:24 -0700, Eric Jacobsen ><eric.jacobsen@ieee.org> wrote: > >>On Mon, 12 Jan 2009 12:39:23 -0800, Rick Lyons >><R.Lyons@_BOGUS_ieee.org> wrote: >> >>>On Mon, 5 Jan 2009 05:44:08 -0800 (PST), Oli Charlesworth >>><catch@olifilth.co.uk> wrote: >>> >>>>On Jan 5, 12:57&#4294967295;pm, jim <".sjedgingN0sp"@m...@mwt.net> wrote: >>>>> Flashman wrote: >>>>> >>>>> > Hello everyone, >>>>> >>>>> > first, please excuse me for spelling or grammer mistakes. >>>>> >>>>> > I was asked to estimate ,with Matlab, an MA filter's (FIR filter) >>>>> > coefficients only from 10,000 output data samples (y(t)) which I've been >>>>> > given on a DAT file. >>>>> >>>>> > The filter is a 3rd order filter, so i need to compute b0, b1, b2, b3 >>>>> > coefficients. The input signal x(t) is a white gaussian noise: >>>>> > x= rand(1,10000) >>>>> >>>>> > now, if I had b0-b3 and had to compute the output y(t), Matlab's filter >>>>> > function can solve it easily. >>>>> > but I don't have a clue how can I estimate b0-b3 from y(t). >>>>> >>>>> Maybe I don't understand the question. If it is a moving average filter with 4 >>>>> coefficients, it looks like a[1 1 1 1] where a is some constant factor of gain. >>>>> If you are asking how to determine what a is by looking only at the output - I >>>>> don't think you can. >>>> >>>>In statistics, the term "moving average" is much more general. See >>>>e.g. http://en.wikipedia.org/wiki/Moving_average_model or >>>>http://en.wikipedia.org/wiki/Autoregressive_moving_average_model. >>> >>>Hi Oli, >>> Ha ha. Language language language. >>> >>>When I first read the OP's words: "MA filter's" I >>>assumed he meant coefficients all having the same >>>value. Then when he wrote: "b0-b3", I wasn't so >>>sure. >>> >>>I don't consider a convolutional FIR filter having >>>different-valued coefficients as a "moving-average >>>filter", because such filters do not compute >>>moving averages. >> >>It does, it's just a weighted average. A boxcar is just a special >>case of an MA filter where the weights are all equal. Since people >>tend to think of "averages" or "means" in the strict statistical >>population analysis sense, it's natural to restrict the term to just >>the boxcar application. Personally I think any FIR is an MA filter, >>it's just the difference of whether the weighting is uniform or not to >>match the more traditional sense of averaging with a boxcar filter. >>>The OP should have been a little more clear. >>>But no super-big deal, such confusion happens all >>>the time here. >>> >>>See Ya', >>>[-Rick-] >> >>So much of the terminology is overloaded or applied slightly >>differently in different applications that it seems like it's always a >>good idea to be careful about defining or clarifying things early on >>in a discussion. >> >>Eric Jacobsen > >Hi Eric, > You're not alone in your opinion. >Our DSP guru pal Maurice Givens (do you remember Maurice >from the COMP.DSP Conference at Danville Signal Proc. >Inc. a few years ago?) just sent >me a private E-mail telling me that's it's definitely >appropriate to refer to any tapped-delay line FIR filter >as a "moving average" filter.
He's a smart guy! You should listen to him. ;)
>Maurice reminded me that an IIR filter having both >feed-forward and feedback taps is called an "auto-regressive >moving average" (ARMA) process. I've seen the "ARMA" >acronym many times before but never gave the terminology >much thought.
Yup, AR => IIR, MA => FIR. Or thereabouts. It's one of those terminology thangs. I think one could write a book about just the terminology hurdles in technology, how terms get overloaded, recycled, etc. There are lots of cases like this where multiple, esoteric, terms are used for the same or very similar things. Like in coding a Maximum A-Posteriori (MAP) and A-Posteriori Probability (APP) decoder are the same thing. Some people object to the MAP terminology because the decoder doesn't really maximize anything, so they use APP. At least it's not confusing. ;)
>I'll have to think some more about how a, for example, >half-band FIR filter can legitimately be called a >"moving average" filter. > >In any case Eric, when you and Maurice both make an effort >to "straighten me out", I'd better pay attention. >So OK, ... from now on when someone refers to an FIR >filter as a "moving average" filter, I'll not >assume the filter coefficients are all equal. > >See Ya', >[-Rick-] >
Eric Jacobsen Minister of Algorithms Abineau Communications http://www.ericjacobsen.org Blog: http://www.dsprelated.com/blogs-1/hf/Eric_Jacobsen.php
On Mon, 12 Jan 2009 21:11:43 -0800 (PST), dbd <dbd@ieee.org> wrote:

  (snipped by Lyons)
> >The rest of your question seems correct about determining the values >of an MA model's coefficients, if you can avoid the language law here. > >Perhaps in sci.math.num-analysis you could find an audience more >accepting of established nomenclature of traditional DSP concepts. > >Dale B. Dalrymple
Hi Dale, I'm not aware of any "language law" here on comp.dsp. But there is one principle that we should all try to follow: "One should aim not at being possible to understand, but at being impossible to misunderstand." Quintilian See Ya', [-Rick-]
On Jan 14, 2:20 pm, Rick Lyons <R.Lyons@_BOGUS_ieee.org> wrote:

> ... > Hi Dale, > I'm not aware of any "language law" here on > comp.dsp. But there is one principle that we > should all try to follow: > > "One should aim not at being possible to understand, > but at being impossible to misunderstand." > Quintilian > > See Ya', > [-Rick-]
Since this is usenet there are no 'laws' of language, or much else, but as the practice of doctors is medicine, the practice of language lawyers (which we seem to have at times) is 'language law'. Dale B. Dalrymple
On Wed, 14 Jan 2009 18:45:46 -0800 (PST), dbd <dbd@ieee.org> wrote:

>On Jan 14, 2:20 pm, Rick Lyons <R.Lyons@_BOGUS_ieee.org> wrote: > >> ... >> Hi Dale, >> I'm not aware of any "language law" here on >> comp.dsp. But there is one principle that we >> should all try to follow: >> >> "One should aim not at being possible to understand, >> but at being impossible to misunderstand." >> Quintilian >> >> See Ya', >> [-Rick-] > >Since this is usenet there are no 'laws' of language, or much else, >but as the practice of doctors is medicine, the practice of language >lawyers (which we seem to have at times) is 'language law'. > >Dale B. Dalrymple
The existence of language law is "only a theory." :-)