Oli Filth wrote:> Jerry Avins said the following on 08/06/2006 22:45: > >> Oli Filth wrote: >> >>> Jerry Avins said the following on 08/06/2006 21:46: >>> >>>> Oli Filth wrote: >>>> >>>>> Jerry Avins said the following on 08/06/2006 15:46: >>>> >>>> >>>> ... >>>> >>>>>> It is equivalent, but needlessly complex. >>>>> >>>>> >>>>> Needlessly complex? It replaces (L-1) operations per sample with 2 >>>>> operations per sample. >>>> >>>> >>>> Compare your two-loop implementation with the more common one-loop >>>> approach. In each case there is one addition and one subtraction, but >>>> the diagram I showed has one fewer loop. I guess complexity, like >>>> beauty, is in the mind of the beholder. >>> >>> >>> Ah sorry, I thought you were saying that the recursive form was >>> "needlessly complex" compared to the non-recursive form. >>> >>> However, I have to admit, I still don't understand the diagram you drew >>> - it still looks like a comb filter to me - where is the addition taking >>> place, or rather, what is being added? >>> >>> Your diagram: >>> >>> +------+ >>> ---+--->| z^-L |------+ >>> | +------+ | - >>> | v >>> +----------- + --->0-------> >> >> >> The diagram is wrong. It should be >> >> +------+ >> ---+--->| z^-L |------+ >> | +------+ | - >> | - v >> | + +------+ >> +------------->| SUM |-----> >> +------+ >> > > This has a (mathematical and practical) zero at DC, and its difference > equation is: > > y[n] = x[n] - x[n-L] > > not: > > y[n] = x[n] - x[n-L] + y[n-1] > > and therefore isn't equivalent to: > > L-1 > y[n] = sum { x[n-i] } > i=0It is the sum of the current sample and the previous L-1 samples, for a total of L in all. What do you mean by a moving sum? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Online · Live + on demand
February 9-11, 2027
Price goes up Nov 1: register now to lock in today's rate
Register Now →
Question on pole-zero cancellation
Started by ●June 7, 2006
Reply by ●June 8, 20062006-06-08
Reply by ●June 8, 20062006-06-08
jim wrote:> > Jerry Avins wrote: > > >>With 32-bit floating point, there are 25 bits in the mantissa counting >>the implied one. Many filters will never accumulate a large enough sum >>to change the exponent, and the operation will be perfect. > > >>That's good and bad. If considering the possibilities, an exponent >>change is known to never happen, that's good. If the fact that it works >>most of the time and accumulates error only slowly and sporadically, >>that can have the bad effect of allowing defective code to survive testing. > > > > So what does that mean in the context of the present discussion? Do you > or do you not get the same results if you implement a box-car filter as > an standard FIR implementation or as a recursive implementation similar > to an IIR? That is if the starting condition are such that both of the 2 > methods start generating the same identical sequences what is the > mechanism that would cause the sequences to diverge over time? > > Whether the operation is perfectly precise or not was not the > question. Loss of precision can occur in either implementation. Over > time what makes you think the result won't be precisely the same even if > not perfectly correct?If the numbers are such that the least significant bit of the float is always the same as the least significant bit of a fixed-point number would be (including the sum in the requirement) then a floating-point implementation will be trouble free. Otherwise, the sum will depart from the proper value with the statistics of a drunkard's walk, taking one step every time the condition is violated. Precision is not the issue. Although the error increases on average only with the square root of the number of steps, eventually, it can become infinite. http://en.wikipedia.org/wiki/Random_walk Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●June 8, 20062006-06-08
jim wrote:> > Jerry Avins wrote: > > >>With 32-bit floating point, there are 25 bits in the mantissa counting >>the implied one. Many filters will never accumulate a large enough sum >>to change the exponent, and the operation will be perfect. > > >>That's good and bad. If considering the possibilities, an exponent >>change is known to never happen, that's good. If the fact that it works >>most of the time and accumulates error only slowly and sporadically, >>that can have the bad effect of allowing defective code to survive testing. > > > > So what does that mean in the context of the present discussion? Do you > or do you not get the same results if you implement a box-car filter as > an standard FIR implementation or as a recursive implementation similar > to an IIR? That is if the starting condition are such that both of the 2 > methods start generating the same identical sequences what is the > mechanism that would cause the sequences to diverge over time? > > Whether the operation is perfectly precise or not was not the > question. Loss of precision can occur in either implementation. Over > time what makes you think the result won't be precisely the same even if > not perfectly correct? >If it's done as an FIR filter then the only errors for a given output will be due to quantization during that iteration of the filter. If it's done as an IIR filter then the quantization errors will tend to accumulate, as Jerry pointed out with an ever growing, ultimately infinite, variance. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Posting from Google? See http://cfaj.freeshell.org/google/ "Applied Control Theory for Embedded Systems" came out in April. See details at http://www.wescottdesign.com/actfes/actfes.html
Reply by ●June 8, 20062006-06-08
Jerry Avins said the following on 09/06/2006 01:43:> Oli Filth wrote: > >> Jerry Avins said the following on 08/06/2006 22:45: >> >>> +------+ >>> ---+--->| z^-L |------+ >>> | +------+ | - >>> | - v >>> | + +------+ >>> +------------->| SUM |-----> >>> +------+ >>> >> This has a (mathematical and practical) zero at DC, and its difference >> equation is: >> >> y[n] = x[n] - x[n-L] >> >> not: >> >> y[n] = x[n] - x[n-L] + y[n-1] >> >> and therefore isn't equivalent to: >> >> L-1 >> y[n] = sum { x[n-i] } >> i=0 > > It is the sum of the current sample and the previous L-1 samples, for a > total of L in all. What do you mean by a moving sum?That's exactly what I mean by a moving sum, but that's not what your block diagram is doing. It's merely subtracting one input sample from another; the other L-1 samples in the delay chain aren't involved. Your version gives a set of L zeros evenly spaced around the unit circle, i.e. a comb filter, whereas a true moving sum has only L-1 zeros as the zero at DC is cancelled. If you have MATLAB, compare the following: freqz([1 0 0 0 -1], 1) % Your version (for L=4) freqz([1 0 0 0 -1], [1 -1]) % My version (for L=4) freqz([1 1 1 1], 1) % Explicit moving sum (for L=4) -- Oli
Reply by ●June 8, 20062006-06-08
Oli Filth wrote:> Hi,...> > This is equivalent to: > > +------+ > ---+--->| z^-L |------+ > | +------+ | - > | v > +----------------->0--->0-----------------+-----> > ^ | > | +------+ | > +-----| z^-1 |<---+ > +------+ > > i.e. implementing the feedforward section before the feedback section, > and doing the two additions separately. > > The feedforward section has already killed the DC component, so we can't > recover it.It is right that the feedforward section 'has already' killed the DC, however, the DC is killed from the time t > 0; when taking t = 0 into consideration, you should find that an initial little PULSE runs through the feedforard section, and the PULSE trigger the feedback section to HIP-HOP, which causes the DC to be recovered.
Reply by ●June 8, 20062006-06-08
Oli Filth wrote: ...>>>> +------+ >>>> ---+--->| z^-L |------+ >>>> | +------+ | - >>>> | - v >>>> | + +------+ >>>> +------------->| SUM |-----> >>>> +------+...> If you have MATLAB, compare the following: > freqz([1 0 0 0 -1], 1) % Your version (for L=4) > freqz([1 0 0 0 -1], [1 -1]) % My version (for L=4) > freqz([1 1 1 1], 1) % Explicit moving sum (for L=4)I don't have Matlab, and it's not worth dragging out MathCad. Compare impulse responses for a string of ones long enough for the transient to have passed, the outputs of my structure and of [1 1 1 1] are a steady 4. For a long string of zeros, both are zero. If now the input takes a step to 2, both outputs become 2, 4, 6, 8, 8, .... Perhaps we are using different conventions. If so, I don't claim that mine is the usual one. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●June 8, 20062006-06-08
Jerry Avins said the following on 09/06/2006 03:19:> Oli Filth wrote: > > ... > >>>>> +------+ >>>>> ---+--->| z^-L |------+ >>>>> | +------+ | - >>>>> | - v >>>>> | + +------+ >>>>> +------------->| SUM |-----> >>>>> +------+ > > ... > >> If you have MATLAB, compare the following: >> freqz([1 0 0 0 -1], 1) % Your version (for L=4) >> freqz([1 0 0 0 -1], [1 -1]) % My version (for L=4) >> freqz([1 1 1 1], 1) % Explicit moving sum (for L=4) > > I don't have Matlab, and it's not worth dragging out MathCad. > > Compare impulse responses for a string of ones long enough for the > transient to have passed, the outputs of my structure and of [1 1 1 1] > are a steady 4.<SNIP>> Perhaps we are using different conventions.I think we must be. I take your diagram to mean "form the n-th output sample by subtracting the (n-L)-th input sample from the n-th input sample", i.e. y[n] = x[n] - x[n-L]. If so, the steady-state output to a long string of ones is definitely (1 - 1) = 0. -- Oli
Reply by ●June 8, 20062006-06-08
Oli Filth wrote:> Jerry Avins said the following on 09/06/2006 03:19: >> Oli Filth wrote: >> >> ... >> >>>>>> +------+ >>>>>> ---+--->| z^-L |------+ >>>>>> | +------+ | - >>>>>> | - v >>>>>> | + +------+ >>>>>> +------------->| SUM |-----> >>>>>> +------+ >> >> ... >> >>> If you have MATLAB, compare the following: >>> freqz([1 0 0 0 -1], 1) % Your version (for L=4) >>> freqz([1 0 0 0 -1], [1 -1]) % My version (for L=4) >>> freqz([1 1 1 1], 1) % Explicit moving sum (for L=4) >> >> I don't have Matlab, and it's not worth dragging out MathCad. >> >> Compare impulse responses for a string of ones long enough for the >> transient to have passed, the outputs of my structure and of [1 1 1 1] >> are a steady 4. > <SNIP> >> Perhaps we are using different conventions. > > I think we must be. I take your diagram to mean "form the n-th output > sample by subtracting the (n-L)-th input sample from the n-th input > sample", i.e. y[n] = x[n] - x[n-L]. If so, the steady-state output to a > long string of ones is definitely (1 - 1) = 0.I intend it to be "form the n-th output sample by subtracting the (n-L)-th input sample from sum of previous N samples. Is this clearer?: +------+ ---+--->| z^-L |-------------------+ | +------+ | | | | +------------+ | +------------->|+ -|<--+ | accumulate |-----> +------------+ Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●June 10, 20062006-06-10
Andor wrote:>[...]Hi Andor, I just came up with a problem with this analysis. Consider the unit step function, u(t). It has a "point-mass" component in the frequency domain at DC: U(w) = 1/(j*w) + pi*delta(w). However, it will pass through such a cascaded system (even a theoretical one) without a problem, will it not? --Randy
Reply by ●June 10, 20062006-06-10
Jerry Avins said the following on 09/06/2006 03:59:> Oli Filth wrote: >> Jerry Avins said the following on 09/06/2006 03:19: >>> Oli Filth wrote: >>> >>> ... >>> >>>>>>> +------+ >>>>>>> ---+--->| z^-L |------+ >>>>>>> | +------+ | - >>>>>>> | - v >>>>>>> | + +------+ >>>>>>> +------------->| SUM |-----> >>>>>>> +------+ >>> >>> ... >>> >>>> If you have MATLAB, compare the following: >>>> freqz([1 0 0 0 -1], 1) % Your version (for L=4) >>>> freqz([1 0 0 0 -1], [1 -1]) % My version (for L=4) >>>> freqz([1 1 1 1], 1) % Explicit moving sum (for L=4) >>> >>> I don't have Matlab, and it's not worth dragging out MathCad. >>> >>> Compare impulse responses for a string of ones long enough for the >>> transient to have passed, the outputs of my structure and of [1 1 1 >>> 1] are a steady 4. >> <SNIP> >>> Perhaps we are using different conventions. >> >> I think we must be. I take your diagram to mean "form the n-th output >> sample by subtracting the (n-L)-th input sample from the n-th input >> sample", i.e. y[n] = x[n] - x[n-L]. If so, the steady-state output to >> a long string of ones is definitely (1 - 1) = 0. > > I intend it to be "form the n-th output sample by subtracting the > (n-L)-th input sample from sum of previous N samples. Is this clearer?: > > +------+ > ---+--->| z^-L |-------------------+ > | +------+ | > | | > | +------------+ | > +------------->|+ -|<--+ > | accumulate |-----> > +------------+ >Ah! Much clearer. :) Then yes, this *is* of course an equivalent system. To go back to your point on complexity, the accumulator-based system is an in-place implementation the unit-length delay line, so requires maybe one less register move, and so you're right, it's marginally less complex. Behaviourally however, they're identical. -- Oli







