From: Pawel on
On Jun 14, 5:01 pm, Tim Wescott <t...(a)seemywebsite.now> wrote:
> On 06/13/2010 09:08 AM, Pawel wrote:
>
>
>
> > On Jun 13, 4:08 pm, Tim Wescott<t...(a)seemywebsite.now>  wrote:
> >> On 06/13/2010 04:44 AM, Pawel wrote:
>
> >>> Dear All,
>
> >>> I have a following question: how does one implement anticausal filter
> >>> with backward filtering (or any other means)?
> >>> I understand that x(n) with a transform X(z) when flipped gives
> >>> flip(x(n)) the transform X(z^-1). According to this I can peform
> >>> following flip(x(n)) and filter with the filter H(z) and then flip
> >>> back the result Y(z)= X(z^-1)H(z) ->flip Y(z)=X(z)H(z^-1), where
> >>> H(z^-1) is the transfrom of anticausal filter. Now if I have unstable,
> >>> causal filter H(z) then H(z^-1) anticausal filter should be stable. I
> >>> can't see how simply flipping x(n) would lead to the stable filter -
> >>> the software do not know if the filter is stable or not it just
> >>> calculate the response from the difference equation. Would the whole
> >>> answer lay in the initial conditions of the filter? Would You please
> >>> point me to some literature dealing with this problem.
>
> >> "I can't see how simply flipping x(n) would lead to the stable filter"
>
> >> By definition, if x(n) is the response to an entirely unstable system,
> >> then all of its components are growing exponentials.  A growing
> >> exponential in positive time is a decaying exponential in negative time
> >> -- hence, stability.
>
> >> If x(n) is the response to a system that is a mix of stable and unstable
> >> elements (i.e. some of it's components grow and some shrink), then
> >> running it in reverse will still result in an unstable system.
>
> >> --
> >> Tim Wescott
> >> Control system and signal processing consultingwww.wescottdesign.com
>
> > Hi Tim,
>
> > Thanks a lot. I am trying to implement this in Matlab, so I do
> > fliplr(x), next filter it with the all-pole filter H(z)=1/[(z-2)(z-3)]
> > - certainly unstable filter, next I flip the result back and I get
> > this ugly skyrocketing response at the beginning (something like
> > 10^46)- would it be caused by the problem of initial conditions. The x
> > is randomly generated data that value varies between 1 and -1 of
> > lenght of 100.
>
> That H(z) certainly should be stable when swapped to H(z^-1) -- you'd
> have a pole at 1/2 and another one at 1/3, which is quite stable and
> settles pretty darn fast.
>
> It's not unheard of for Matlab to have obscure implementation issues
> that make it hard to use their canned software right, or to just have
> the occasional outright bug -- it keeps you on your toes.  So you may
> want to try verifying each step, to make sure that you're getting all
> the pieces right.
>
> --
> Tim Wescott
> Control system and signal processing consultingwww.wescottdesign.com

Tim,

Thanks again. That is what I am trying to understand - I am new to
DSP. I am trying to convey useful tehcniques to another area of
science/engineering - do I actually need to flip filter coefficients
before filtering as well as flipping signal -
x - input signal, H=a(z)/b(z) do I need to perform

1) x(-n)=flip(x) AND H(z^-1)=flip(a(z)/b(z)), next filter(x(-
n),H(z^-1)), next flip the result of filtering OR is it enough to
2) x(-n)=flip(x), next filter(x(-n),H(z)) and flip the result back

Which of those two options is correct - I am starting to expect that
the 1) since otherwise 2) would still result in filtering with
unstable filter of flipped signal x(n). Am I right?

Thanks for Your valuable time but I was not able to find straight
answer to my dilemma nor in books or on the web.

Regards

Pawel
From: Tim Wescott on
On 06/15/2010 09:21 AM, Pawel wrote:
> On Jun 14, 5:01 pm, Tim Wescott<t...(a)seemywebsite.now> wrote:
>> On 06/13/2010 09:08 AM, Pawel wrote:
>>
>>
>>
>>> On Jun 13, 4:08 pm, Tim Wescott<t...(a)seemywebsite.now> wrote:
>>>> On 06/13/2010 04:44 AM, Pawel wrote:
>>
>>>>> Dear All,
>>
>>>>> I have a following question: how does one implement anticausal filter
>>>>> with backward filtering (or any other means)?
>>>>> I understand that x(n) with a transform X(z) when flipped gives
>>>>> flip(x(n)) the transform X(z^-1). According to this I can peform
>>>>> following flip(x(n)) and filter with the filter H(z) and then flip
>>>>> back the result Y(z)= X(z^-1)H(z) ->flip Y(z)=X(z)H(z^-1), where
>>>>> H(z^-1) is the transfrom of anticausal filter. Now if I have unstable,
>>>>> causal filter H(z) then H(z^-1) anticausal filter should be stable. I
>>>>> can't see how simply flipping x(n) would lead to the stable filter -
>>>>> the software do not know if the filter is stable or not it just
>>>>> calculate the response from the difference equation. Would the whole
>>>>> answer lay in the initial conditions of the filter? Would You please
>>>>> point me to some literature dealing with this problem.
>>
>>>> "I can't see how simply flipping x(n) would lead to the stable filter"
>>
>>>> By definition, if x(n) is the response to an entirely unstable system,
>>>> then all of its components are growing exponentials. A growing
>>>> exponential in positive time is a decaying exponential in negative time
>>>> -- hence, stability.
>>
>>>> If x(n) is the response to a system that is a mix of stable and unstable
>>>> elements (i.e. some of it's components grow and some shrink), then
>>>> running it in reverse will still result in an unstable system.
>>
>>>> --
>>>> Tim Wescott
>>>> Control system and signal processing consultingwww.wescottdesign.com
>>
>>> Hi Tim,
>>
>>> Thanks a lot. I am trying to implement this in Matlab, so I do
>>> fliplr(x), next filter it with the all-pole filter H(z)=1/[(z-2)(z-3)]
>>> - certainly unstable filter, next I flip the result back and I get
>>> this ugly skyrocketing response at the beginning (something like
>>> 10^46)- would it be caused by the problem of initial conditions. The x
>>> is randomly generated data that value varies between 1 and -1 of
>>> lenght of 100.
>>
>> That H(z) certainly should be stable when swapped to H(z^-1) -- you'd
>> have a pole at 1/2 and another one at 1/3, which is quite stable and
>> settles pretty darn fast.
>>
>> It's not unheard of for Matlab to have obscure implementation issues
>> that make it hard to use their canned software right, or to just have
>> the occasional outright bug -- it keeps you on your toes. So you may
>> want to try verifying each step, to make sure that you're getting all
>> the pieces right.
>>
>> --
>> Tim Wescott
>> Control system and signal processing consultingwww.wescottdesign.com
>
> Tim,
>
> Thanks again. That is what I am trying to understand - I am new to
> DSP. I am trying to convey useful tehcniques to another area of
> science/engineering - do I actually need to flip filter coefficients
> before filtering as well as flipping signal -
> x - input signal, H=a(z)/b(z) do I need to perform
>
> 1) x(-n)=flip(x) AND H(z^-1)=flip(a(z)/b(z)), next filter(x(-
> n),H(z^-1)), next flip the result of filtering OR is it enough to
> 2) x(-n)=flip(x), next filter(x(-n),H(z)) and flip the result back
>
> Which of those two options is correct - I am starting to expect that
> the 1) since otherwise 2) would still result in filtering with
> unstable filter of flipped signal x(n). Am I right?

You are correct. You want choice 1. This makes sense, because if you
just flipped the time-sense of one half of the problem, then your filter
would be running backwards with respect to the data; then you wouldn't
get the answer you wanted, even if things stayed stable.

> Thanks for Your valuable time but I was not able to find straight
> answer to my dilemma nor in books or on the web.

Information on this stuff often comes in a very condensed form, and
unpacking it for a particular application is left as an exercise for the
reader.

This is good and bad -- it can take longer sometimes to find a specific
solution to a specific problem (this group helps), but knowing the
general theory and being able to descend from the theory to the specific
gives you the ability to solve problems that no one has ever solved
before, which can be much to your advantage.

Since DSP is a field where the fundamentals weigh more heavily on the
final result than almost any other that I can think of, it is a good
idea to learn all the fundamentals you can, learn how to extend those
fundamentals to solve a specific problem, learn when they apply and
learn when they don't.

--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
From: Jerry Avins on
On 6/15/2010 12:21 PM, Pawel wrote:
> On Jun 14, 5:01 pm, Tim Wescott<t...(a)seemywebsite.now> wrote:
>> On 06/13/2010 09:08 AM, Pawel wrote:
>>
>>
>>
>>> On Jun 13, 4:08 pm, Tim Wescott<t...(a)seemywebsite.now> wrote:
>>>> On 06/13/2010 04:44 AM, Pawel wrote:
>>
>>>>> Dear All,
>>
>>>>> I have a following question: how does one implement anticausal filter
>>>>> with backward filtering (or any other means)?
>>>>> I understand that x(n) with a transform X(z) when flipped gives
>>>>> flip(x(n)) the transform X(z^-1). According to this I can peform
>>>>> following flip(x(n)) and filter with the filter H(z) and then flip
>>>>> back the result Y(z)= X(z^-1)H(z) ->flip Y(z)=X(z)H(z^-1), where
>>>>> H(z^-1) is the transfrom of anticausal filter. Now if I have unstable,
>>>>> causal filter H(z) then H(z^-1) anticausal filter should be stable. I
>>>>> can't see how simply flipping x(n) would lead to the stable filter -
>>>>> the software do not know if the filter is stable or not it just
>>>>> calculate the response from the difference equation. Would the whole
>>>>> answer lay in the initial conditions of the filter? Would You please
>>>>> point me to some literature dealing with this problem.
>>
>>>> "I can't see how simply flipping x(n) would lead to the stable filter"
>>
>>>> By definition, if x(n) is the response to an entirely unstable system,
>>>> then all of its components are growing exponentials. A growing
>>>> exponential in positive time is a decaying exponential in negative time
>>>> -- hence, stability.
>>
>>>> If x(n) is the response to a system that is a mix of stable and unstable
>>>> elements (i.e. some of it's components grow and some shrink), then
>>>> running it in reverse will still result in an unstable system.
>>
>>>> --
>>>> Tim Wescott
>>>> Control system and signal processing consultingwww.wescottdesign.com
>>
>>> Hi Tim,
>>
>>> Thanks a lot. I am trying to implement this in Matlab, so I do
>>> fliplr(x), next filter it with the all-pole filter H(z)=1/[(z-2)(z-3)]
>>> - certainly unstable filter, next I flip the result back and I get
>>> this ugly skyrocketing response at the beginning (something like
>>> 10^46)- would it be caused by the problem of initial conditions. The x
>>> is randomly generated data that value varies between 1 and -1 of
>>> lenght of 100.
>>
>> That H(z) certainly should be stable when swapped to H(z^-1) -- you'd
>> have a pole at 1/2 and another one at 1/3, which is quite stable and
>> settles pretty darn fast.
>>
>> It's not unheard of for Matlab to have obscure implementation issues
>> that make it hard to use their canned software right, or to just have
>> the occasional outright bug -- it keeps you on your toes. So you may
>> want to try verifying each step, to make sure that you're getting all
>> the pieces right.
>>
>> --
>> Tim Wescott
>> Control system and signal processing consultingwww.wescottdesign.com
>
> Tim,
>
> Thanks again. That is what I am trying to understand - I am new to
> DSP. I am trying to convey useful tehcniques to another area of
> science/engineering - do I actually need to flip filter coefficients
> before filtering as well as flipping signal -
> x - input signal, H=a(z)/b(z) do I need to perform
>
> 1) x(-n)=flip(x) AND H(z^-1)=flip(a(z)/b(z)), next filter(x(-
> n),H(z^-1)), next flip the result of filtering OR is it enough to
> 2) x(-n)=flip(x), next filter(x(-n),H(z)) and flip the result back
>
> Which of those two options is correct - I am starting to expect that
> the 1) since otherwise 2) would still result in filtering with
> unstable filter of flipped signal x(n). Am I right?
>
> Thanks for Your valuable time but I was not able to find straight
> answer to my dilemma nor in books or on the web.

The math is getting in your way. Set DSP aside for now. Run an analog
square wave through a low-pass RC filter consisting of a series R with
the output taken across a shunt C. Tape record the output as you look at
it with an oscilloscope. Think of the original waveform as a sequence of
steps of alternating polarity. Note that the leading edges of the steps
are virtually unchanged, while the trailing edges are rounded. This
asymmetry is a sign that in addition to attenuating low frequencies, the
filter has delayed high frequencies more than lower ones.

Now play the tape backwards. (If your player won't run in reverse,
unwind the tape and wind it on again from the other end.) Observe that
the leading edges are rounded, while the trailing edges show sharp
corners. This asymmetry is a sign that in addition to attenuated low
frequencies, high frequencies have been advanced relative to lows. By
running the tape backward, we have effectively reversed time. (Well, we
at least reversed sequence.) What was a phase lag before reversal
becomes a phase lead afterward.

Play the tape backward again, this time through the original filter, the
one that delayed the highs. Just as before, the trailing edges are
rounded by the filter. Since the leading edges were already rounded, the
doubly filtered waveform has lost even more of its highs and is again
symmetric. In addition to further attenuating highs, the filter has
delayed the advanced components, with the net result that all signal
components have the same relative phase as the unfiltered square wave.

Note that the signal was reversed, not the filter. It would make no
sense to apply the signal to a shunt capacitor and put a resistor
between the signal and the output. If the output impedance of the driver
were low enough and the input impedance of the 'scope were high enough,
that filter would have no effect.

Jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������
From: Tim Wescott on
On 06/15/2010 10:37 AM, Jerry Avins wrote:
-- snip --
> Note that the signal was reversed, not the filter. It would make no
> sense to apply the signal to a shunt capacitor and put a resistor
> between the signal and the output. If the output impedance of the driver
> were low enough and the input impedance of the 'scope were high enough,
> that filter would have no effect.

Actually, to reverse that filter you'd need to find a device with
negative capacitance. This would be difficult, as any causal linear
negative-capacitance device would be storing huge amounts of negative
energy at very high voltages.

--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
From: Tim Wescott on
On 06/15/2010 11:24 AM, Tim Wescott wrote:
> On 06/15/2010 10:37 AM, Jerry Avins wrote:
> -- snip --
>> Note that the signal was reversed, not the filter. It would make no
>> sense to apply the signal to a shunt capacitor and put a resistor
>> between the signal and the output. If the output impedance of the driver
>> were low enough and the input impedance of the 'scope were high enough,
>> that filter would have no effect.
>
> Actually, to reverse that filter you'd need to find a device with
> negative capacitance. This would be difficult, as any causal linear
> negative-capacitance device would be storing huge amounts of negative
> energy at very high voltages.
>
Oops -- I forgot the :-)

--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com