Re: Large moving average



Jerry Avins wrote:
dave_bonnell@xxxxxxxxxxx wrote:
....
Fortunately, a simple moving average is adequate for my purposes. The
intent is to do the following in a circular buffer:

y = y + x[n] - x[n-m]

That is an FIR filter. It's not suitable for floating-point implementation.

I did a double-take when I saw this.

I'm sure Jerry didn't mean to indicate that all FIR filters are
unsuitable for floating-point calculations.

In case I'm not the only one who misunderstood, I will clarify.

Using feedback in the above manner described leads to a potentially
unstable situation -- a pole on the unit circle.

e.g. consider a floating point moving average of three samples across
the sequence. For simplicity sake, ignore the division by 3.

input: [ 1e20 2e20 3e20 4e20 5 0 0 0 0 0 ]

step 1: 1e20 + 2e20 + 3e20 = 6e20. Correct
step 2: 6e20 + 4e20 - 1e20 = 9e20. Correct
step 3: 9e20 + 5 - 2e20 = 7e20. Sort of correct
step 4: 7e20 + 0 - 3e20 = 4e20. Sort of correct
step 5: 4e20 + 0 - 4e20 = 0 . Wrongo!! should be 5
step 6: 0 + 0 - 5 =-5 . Wrongo!! should be 0

The problem is that the quantization error depends on the amount
currently in the sum.

A constant quantization unit, such as with fixed-point processing,
prevents drift.

--
Mark Borgerding
.



Relevant Pages

  • Re: Large moving average
    ... That is an FIR filter. ... It's not suitable for floating-point implementation. ... A constant quantization unit, such as with fixed-point processing, ...
    (comp.dsp)
  • Re: FIR FIlter
    ... as the FIR filter is a sum of products. ... floating-point coefs of hcan better represent little things like ... the heavily attenuated stopband than fixed-point coefs. ...
    (comp.dsp)