I am practicing some DSP techniques along with desktop application development using Python and PyQt. In my filter design application, I am able to create a filter by placing zeros and poles on a unit circle plot and then apply this filter to imported signal data or generate a signal by the movement of the mouse on a mouse pad area I defined in my code. However, a weird effect happened, when I generated a signal by mouse and applied a high-pass filter (zero at (0.5, 0) and pole at (-0.9, 0), a zigzag pattern (I don't exactly know what its name is) appeared in the filtered data, like it was multiplied by the whole signal. though this effect doesn't happen on an imported signal. In my code, I am using SciPy to apply the filter in the following line:

self.filtered_data = signal.lfilter(
        self.numerator, self.denominator, self.original_data

As for the signal generation, I'm just getting the 'y' values of mouse movement along a PyQtgraph plotwidget.

The Designed Filter The Mouse-Generated Signal before and after Can anyone just refer to what the reason may be to learn it and solve it?


2 Answers 2


There is nothing unstable here, this looks perfectly correct. The ripple that you see is the transient response of the filter. Your input signal starts at an amplitude of about 200 and you implicitly assume that anything earlier in time is zero. So the signal starts with a very large step and you see (more or less) the step response of the filter.

Let's take a quick look: the pole and zero at $z=0$ cancel so you are left with one zeros at $z=0.5$ and a single pole at $z = -.09$. Here is the step response enter image description here

If you don't see the ripple in imported data, it's probably because the data starts at 0. If you want to avoid the ripple, you need to initialize the filter states properly.

This looks pretty much like what you are getting.


"Unstable" in a dynamic systems context means something different from the colloquial meaning of the word.

Colloquially, if you sit on a chair and it wobbles it is unstable -- even though it never falls over. In a dynamic systems context, the chair would be unstable if it wobbles harder and harder until it falls down, breaks apart, shoots through the wall, etc..

More formally, colloquially, "unstable" means "moves in an unwanted way when you push on it".

On the other hand, "stable" in a dynamic systems context means "the output stays within bounds". This is usually refined as "bounded input bounded output" stability, meaning that for any input that doesn't grow to infinity, the output won't grow infinitely large.

So, roughly, in dynamic systems "unstable" means "we didn't tell it to, but the output just gets bigger and bigger and bigger" -- in linear systems this means its amplitude grows exponentially or linearly; nonlinear systems get to exhibit whatever bizarre behavior they want to.

A filter that rings but settles down, like your filter, is stable.

The zig-zag pattern you are seeing is an artifact of having a pole with a real value in the range $-1 < z < 0$. For any pole at $z = d$, the resulting time-domain response of a filter will have a component that goes as $A d^n$. For $d = -0.9$, it's contribution to the response will be $1, -0.9, 0.81, -0.729, \cdots$. That is what you are seeing in your "zig zag" ringing.

I'm not sure why you did not see this with your imported signal, but I suspect that signal was smooth enough that it did not excite that pole in your filter.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.