1
$\begingroup$

There is a low pass filter with difference equation already provided.

$$ y_n = (x_n - 2x_{n-6} + x_{n-12}) - (-2y_{n-1} + y_{n-2}) $$

$$ a_0 = 1, a_1 = -2, a_2 = 1 $$ $$ b_0 = 1, b_6 = -2, b_{12} = 1 $$

However the filter was designed with some gain as the filtered output is significantly exceeds original signal dynamic range x1 = scipy.signal.lfilter(b, a, x)

Is it possible to normalize filter coefficients to have the same as input signal dynamic range or approximately redesign it from filter frequency response?

$\endgroup$

1 Answer 1

2
$\begingroup$

In general, divide each of the $b$ coefficients by the maximum gain of your filter. This is equivalent to adding an attenuator before or after the original filter.

In this particular case, the maximum gain seems to occur at frequency 0 (where there is a double zero-pole cancellation).

At frequency 0, the gain of your filter is 36. So divide $b[]$ by 36.

Edit: the math

The frequency response comes from evaluating $H(z)$ at $z = e^{j\theta}$. Substituting and operating, and ignoring the phase, you get:

$|H(e^{j\theta})| = \frac{\sin(\theta/2)^2}{\sin(6\theta/2)^2}$

Taking the limit as $\theta \rightarrow 0$ you get $H(e^{j0}) = 36$.

Note that this is a simpler (and well known) filter applied twice. It corresponds the moving average of 6 samples (with the 1/6 factor missing).

So it is like two filters in cascade, each of which sums 6 consecutive samples. Each is a low-pass filter with gain 6 at 0 frequency.

$\endgroup$
6
  • $\begingroup$ thank you, let me have a try. how did you manage to estimate it? I've got another high pass filter with a similar problem $\endgroup$ Commented Jul 9, 2015 at 15:35
  • $\begingroup$ that is from w,h = scipy.signal.freqz(b,a) examination of first values in h? $\endgroup$ Commented Jul 9, 2015 at 15:41
  • 1
    $\begingroup$ This is from doing the math. I never used scipy (yet). $\endgroup$
    – Juancho
    Commented Jul 9, 2015 at 15:44
  • $\begingroup$ can you direct me to the approach? I've looked at the filter frequency response and at frequency of 0 the max value is indeed 36 $\endgroup$ Commented Jul 9, 2015 at 15:45
  • 1
    $\begingroup$ It is a low-pass filter, so you have to measure your attenuation using signals that actually pass through the filter (with components below $\pi/6$). Try with a constant, or with a low frequency sinusodial. $\endgroup$
    – Juancho
    Commented Jul 9, 2015 at 15:53

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.