0
$\begingroup$

I have a C code in which the IIR filter(BiQuad) uses only 4 (normalized) coefficients per stage (a2/a0,a1/a0,b2/b0,b1/b0) instead of 6 coefficients (a0,a1,a2,b0,b1,b2). I know that the value of a0 is always 1. So, it is easy to find the true values of the a2,a1 coefficients (since a0 value is 1). But, i wanted to know the true values of b0, b1, b2.

So, I just want to know is there any way to retrieve/derive the true values of "b" coefficients? One of my friends told me that we can get the values by using Matlab / octave? But, I have no idea how to do it? enter image description here

$\endgroup$

2 Answers 2

2
$\begingroup$

Note that a biquad has $5$ degrees of freedom (not $6$), because $a_0$ can always be chosen as $a_0=1$ without loss of generality:

$$\begin{align}H(z)&=\frac{b_0+b_1z^{-1}+b_2z^{-2}}{1+a_1z^{-1}+a_2z^{-2}}\\&=b_0\cdot\frac{1+\hat{b}_1z^{-1}+\hat{b}_2z^{-2}}{1+a_1z^{-1}+a_2z^{-2}},\qquad \hat{b}_1=\frac{b_1}{b_0},\;\;\hat{b}_2=\frac{b_2}{b_0}\tag{1}\end{align}$$

Eq. $(1)$ shows that $b_0$ is just an overall gain (for fixed values of $\hat{b}_1$ and $\hat{b}_2$), as you've noted yourself.

If you don't know the formula that produced the filter coefficients, there is generally no way to know the intended gain. As mentioned in Dan's answer, the gain is often chosen such that quantization effects are minimized. It can often be compensated for after all computations have been performed.

In some cases, however, it is possible to estimate the intended gain. E.g., if the biquad is a low pass filter, it is reasonable to assume that the original frequency response has a value of $1$ at DC. This means that

$$b_0\frac{1+\frac{b_1}{b_0}+\frac{b_2}{b_0}}{1+a_1+a_2}=1\tag{2}$$

Similarly, for a high pass filter a common scaling makes sure that the frequency response equals $1$ at Nyquist, which implies

$$b_0\frac{1-\frac{b_1}{b_0}+\frac{b_2}{b_0}}{1-a_1+a_2}=1\tag{3}$$

You can come up with similar guesses for the intended scaling for other standard filter types, like band pass filters (unity gain at the center frequency) and band stop filters (unity gain at DC and/or Nyquist).

$\endgroup$
6
  • $\begingroup$ Hi Matt, thanks for explaining using equations. But I don't have complete understanding regarding how you derived the equations (2) and equations (3) from the equation (1). I found out when w = 0, z = 1 which makes Z^(-1) also 1 (Using z = e ^ jw relation). And when w = pi, z = -1, which makes z ^ (-1) also -1. Can you explain the reason why we are considering w = 0 for a low pass filter and w = pi for high pass filter? $\endgroup$
    – rkc
    Jun 14, 2020 at 10:54
  • $\begingroup$ Also, I want to know what value of w we need to consider while designing a bandpass filter since I am using a bandpass filter in my case which allows frequencies from 150Hz to 12KHz. I found that in the discrete domain, the frequency varies from -(w,w), but I don't have a complete understanding of this statement. $\endgroup$
    – rkc
    Jun 14, 2020 at 10:54
  • 1
    $\begingroup$ @rkc: You basically got it figured out, $z=1$ is DC and $z=-1$ is Nyquist. It seems reasonable that a low pass filter passes DC with gain $1$, whereas a high pass filter passes Nyquist (maximum frequency) with gain $1$. $\endgroup$
    – Matt L.
    Jun 14, 2020 at 10:56
  • $\begingroup$ @ Matt L In my case, I am using a Bandpass filter which passes the frequencies from 150Hz to 12KHz. So, the center frequency of the bandpass filter is around 1341 Hz ( by using the formulae f_cen^2 = f_upper * f_lower). I am using a sampling frequency of 32KHz. So 16 kHz corresponds to Nyquist frequency which corresponds to pi in the "w" domain. Using this relation, the calculated center frequency 1341Hz corresponds to (67 / 80) * pi in the "w" domain (approximate). So, I have to replace w with (67 / 80) * pi while calculations, right? $\endgroup$
    – rkc
    Jun 14, 2020 at 11:35
  • 1
    $\begingroup$ @rkc: $1341/16000$ is not the same as $67/80$. Apart from that, you're OK I guess. $\endgroup$
    – Matt L.
    Jun 14, 2020 at 11:44
0
$\begingroup$

It is simply a scaling. If you use $b0=1$ for example, you have the values for $b2$ and $b1$ directly. In contrast if you use $b0=2$ then the filter would have twice the gain and the values for $b2$ and $b1$ would be double. It is that simple. Where you really need to pay attention to the actually scaling used is when you implement the filter with fixed point precision as incorrect scaling can result in much larger quantization noise, but otherwise it will be rather arbitrary similar to scaling your final output.

$\endgroup$
4
  • $\begingroup$ Hi Dan, thanks for the response. I agree that as b0 value changes, the overall response of the filter changes. But, I want to know how to calculate the b0 value if I have all other coefficients in normalized form. Let's say my filter coefficients (a2/a0, a1/a0, b2/b0, b1/b0) are -0.95,1.95,1.0,-1.99. Then is there any way to calculate the b0 value? I am using only float values in my code (not using any fixed-point numbers). So, I am not any issue with precision losses. $\endgroup$
    – rkc
    Jun 12, 2020 at 14:56
  • $\begingroup$ Also, I want to know what advantages do normalized coefficients gives? $\endgroup$
    – rkc
    Jun 12, 2020 at 15:02
  • $\begingroup$ @rkc Pick any value you want. What range from smallest to largest do you want your output to be and scale it based on that (given you are floating point). If it were me, I would just pick 1. Your remaining question is not answerable as it is just like asking this: "My floating point output now has a range from 1 to 10. I have a gain stage after my output. What gain should I use?" $\endgroup$ Jun 12, 2020 at 17:44
  • $\begingroup$ And for your second question the advantage is very clear-- the filter is defined with 4 values instead of 6. $\endgroup$ Jun 12, 2020 at 17:46

Your Answer

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

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