【お知らせ】この部分は英語原文のみでの提供となります。何卒ご了承ください。

2.78.3 Algorithm FIR Filter

Contents

Least Squares

Design a linear-phase FIR filter by the least-squares algorithm, which is to minimize the weighted integrated squared error between the actual amplitude and the desired amplitude. Currently, only Type I and Type II FIR filters are available.

The following reference has described the theoretical approach used during the implementation of this algorithm.

Parks, Thomas W., and C. Sidney Burrus. Digital Filter Design. Hoboken, NJ: John Wiley & Sons, 1987, pp. 54–83.

Window

Design window-based FIR filter.

Algorithm

  1. Perform the same algorithm as Least Squares above, and get the coefficients.
  2. Do element-wise multiplication of the coefficients and window data.

Window Type

Supported windows are listed in the following table, and the related equations are used for generating the coefficients of the window.

Window Name Equation Description
Bartlett
\(w[n] = \left\{
\begin{aligned} 
&\frac{2n}{N}, &0\le n \le \frac{N}{2} \\
&2-\frac{2n}{N}, &\frac{N}{2}\le n \le N
\end{aligned}\right.\)

The window length is \(L=N+1\)

The Bartlett window always has zeros at the first and last samples. For one point window, \(L=1\), return value 1.
Bartlett-Hanning
\[w[n]=0.62-0.48|\frac{n}{N}-0.5|+0.38\cos\left(2\pi(\frac{n}{N}-0.5)\right)\]

where \(0\le n \le N\), and the window length is \(L=N+1\)

This is modified Bartlett-Hanning window, which is a linear combination of weighted Bartlett and Hanning windows, and has near sidelobes lower than both Bartlett and Hanning windows, and far sidelobes lower than both Bartlett and Hamming windows.
Blackman
\[w[n] = 0.42-0.5\cos\left(\frac{2\pi n}{L-1}\right)+0.08\cos\left(\frac{4\pi n}{L-1}\right), 0\le n\le M-1\]

where the window length is \(L\), and \(M\) is \(L/2\) when \(L\) is even and \((L+1)/2\) when \(L\) is odd.

In FIR filter, the symmetric case is used, which reflects the first half around the midpoint to get the second half of the Blackman window, where \(M\le n\le L-1\)
Blackman-Harris
\[w[n] = a_0 - a_1 \cos\left(\frac{2\pi n}{L-1}\right) + a_2\cos\left(\frac{4\pi n}{L-1}\right) - a_3\cos\left(\frac{6\pi n}{L-1}\right)\]

where the window length is \(L\), and \(a_0 = 0.35875, a_1 = 0.48829, a_2 = 0.14128, a_3 = 0.01168\)

This equation is for the symmetric minimum four-term Blackman-Harris window, which is used in FIR filter.
Bohman
\[w[n] = (1 - \frac{2|n|}{L-1})\cos\left(\frac{2\pi|n|}{L-1}\right)+\frac{1}{\pi}\sin\left(\frac{2\pi|n|}{L-1}\right), -\frac{L-1}{2}\le n \le \frac{L-1}{2}\]

where the window length is \(L\).

The first and last values of the Bohman window are always forced to be zero.
Chebyshev The Chebyshev window is defined in the frequency domain using Chebyshev polynomials of the first kind \(T_n(x)\). The Chebyshev polynomials are defined by:
\[T_n(x)=\left\{\begin{aligned}&\cos(n\cos^{-1}x), &|x| \le 1 \\
&\cosh(n\cosh^{-1}x), &|x| > 1\end{aligned}\right.\]

1. Definition in Frequency Domain

The zero-phase frequency response \(W_0(k)\) of a length-N Chebyshev window is given by:

\[W_0(k)=\frac{T_{N-1}(\beta\cos(\frac{\pi k}{N}))}{T_{N-1}(\beta)}\]

where \(N\) is the length of the window sequence, \(T_{N-1}(x)\) is the (N-1)-th order Chebyshev polynomial of the first kind, and \(\beta\) controls the sidelobe attenuation level, which is defined by:

\[\beta=\cosh(\frac{1}{N-1}\cosh^{-1}(10^{\frac{\gamma}{20}}))\]

where \(\gamma\) in dB, the sidelobes are \(-20\gamma\) dB down from the mainlobe.

2. Time-Domain

The time-domain windown is obtained by calculating the inverse discrete Fourier transform of the frequency-domain representation \(W_0(k)\), and then scale the maximum value to 1.

\[w[n] = \frac{1}{N}\sum_{k=0}^{N-1}W_0(k)\exp(\frac{2\pi nkj}{N})\]

where \(n=0, 1, \dots, L-1\), and the window length is \(L\).

In the calculation of \(W_0(k)\), the denominator is not calculated, and after the inverse Fourier transform the window is scaled by making its maximum value unitary.

The Chebyshev window has a Fourier transform magnitude r dB below the mainlobe magnitude. For the definition of the Chebyshev window, see Peter Lynch, "The Dolph-Chebyshev Window: A Simple Optimal Filter", Monthly Weather Review, Vol. 125, pp. 655-660, April 1997.
Flat Top
\[w[n] = a_0 - a_1 \cos\left(\frac{2\pi n}{L-1}\right) + a_2\cos\left(\frac{4\pi n}{L-1}\right) - a_3\cos\left(\frac{6\pi n}{L-1}\right) + a_4\cos\left(\frac{8\pi n}{L-1}\right)\]

where the window length is \(L\), and \(0\le n\le L-1\), \(a_0 = 0.21557895, a_1 = 0.41663158, a_2 = 0.277263158, a_3 = 0.083578947, a_4 = 0.006947368\)

Flat top window is summation of cosines.
Gaussian
\[w[n] = e^{-\frac{1}{2}\left(\frac{2\alpha n}{L-1}\right)^2}\]

where the window length is \(L\), \(-(L-1)/2\le n \le (L-1)/2\)

\(\alpha\) is inversely proportional to the standard deviation of a Gaussian random variable.
Hamming
\[w[n] = 0.54 - 0.46\cos\left(\frac{2\pi n}{L-1}\right), 0\le n \le L-1\]

The window length is \(L\)

The symmetric Hamming window is used for FIR filter.
Hanning
\[w[n] = 0.5\left(1-\cos\left(2\pi\frac{n}{L-1}\right)\right), 0\le n\le L-1\]

The window length is \(L\)

The symmetric Hanning window is used for FIR filter.
Kaiser
\[w[n] = \frac{I_0\left(\beta\sqrt{1-\left(\frac{n-N/2}{N/2}\right)^2}\right)}{I_0(\beta)}, 0\le n\le N\]

The window length is \(L\), and \(N = L-1\), \(I_0\) is the zeroth-order modified Bessel function of the first kind.

The Kaiser window can be used to estimate the minimum filter order for FIR filter.
Nuttall
\[w[n] = a_0 - a_1\cos\left(2\pi\frac{n}{L-1}\right)+a_2\cos\left(4\pi\frac{n}{L-1}\right)-a_3\cos\left(6\pi\frac{n}{L-1}\right)\]

The window length is \(L\), and \(a_0 = 0.3635819, a_1 = 0.4891775, a_2 = 0.1365995, a_3 = 0.0106411\)

The symmetric Nuttall defined four-term Blackman-Harris window is used for FIR filter.
Parzen
\[w[n]=\left\{
\begin{aligned}
&1 - 6\left(\frac{|n|}{L/2}\right)^2 + 6\left(\frac{|n|}{L/2}\right)^3, &0 \le |n| \le (L-1)/4 \\
&2\left(1-\frac{|n|}{L/2}\right)^3, &(L-1)/4 \le |n| \le (L-1)/2
\end{aligned}
\right.\]

The window length is \(L\)

Parzen (de la Vallée Poussin) window are piecewise-cubic approximations of Gaussian windows.
Rectangle
\[w[n] = 1, 0\le n \le L-1\]

The window length is \(L\)

All values are 1 for rectangular window.
Taylor The window length is \(L\), two specified parameters \(\bar{n}\) and \(SLL\).
\(A = \frac{1}{\pi}\cosh^{-1}\left(10^{SLL/20}\right)\)
\(S = \frac{\bar{n}^2}{A^2+(\bar{n}-0.5)^2}\)
\(x[n] = \frac{2(n+1)-1-L}{L}, 0\le n < L\)
\(F_m(m) = \frac{(-1)^{m+1}}{2}\frac{\displaystyle\prod_{n=1}^{\bar{n}-1}\left(1-\frac{m^2}{S(A^2+(n-0.5)^2)}\right)}{\displaystyle\prod_{n=1,n\neq m}^{\bar{n}-1}\left(1-\frac{m^2}{n^2}\right)},m=1,2,\dots,\bar{n}-1\)
\(w[n] = 1+2\displaystyle\sum_{m=1}^{\bar{n}-1}F_m(m)\cos(\pi mx[n]), 0\le n < L\)
Two parameters: \(\bar{n}\) is the number of nearly constant-level sidelobes adjacent to the mainlobe and \(SLL\) is the maximum sidelobe level relative to mainlobe peak, in dB.
Triangular The window length is \(L\).

If \(L\) is odd:

\[w[n] = \left\{
\begin{aligned}
&\frac{2n}{L+1}, &1\le n \le\frac{L+1}{2} \\
&2-\frac{2n}{L+1}, &\frac{L+1}{2}+1\le n \le L
\end{aligned}\right.\]

If \(L\) is even:

\[w[n] = \left\{
\begin{aligned}
&\frac{2n-1}{L}, &1\le n \le\frac{L}{2} \\
&2-\frac{2n-1}{L}, &\frac{L}{2}+1\le n \le L
\end{aligned}\right.\]
Empty
Tukey The window length is \(L\), \(r\) is specified parameter.
\(x[n] = \frac{n}{L-1}, 0\le n\le L-1\)
\(TL = \lfloor \frac{r}{2(L-1)} \rfloor + 1, TH=L-TL\)
\(w[n]=\left\{ \begin{aligned} &\frac{1}{2}\left(1+\cos\left(\frac{2\pi}{r}(x[n]-r/2)\right)\right), &0\le n < TL \\ &1, &TL\le n < TH \\ &\frac{1}{2}\left(1+\cos\left(\frac{2\pi}{r}(x[n]-1+r/2)\right)\right), &TH \le n \le L-1 \end{aligned} \right.\)
The parameter \(r\) is the ratio of cosine-tapered section length to the entire window length, in range of \([0, 1]\). If \(r\le 0\), return rectangular window. If \(r \ge 1\), return Hanning window.
User Defined No equation. If the window data is defined by user, the values can be selected from worksheet column.

Minimum Filter Order

According to a set of specifications in frequency domain, estimate the minimum FIR filter order that will approximately meet the specifications by Kaiser window. Empirically, the derived formulas for estimating the orders of lowpass filters is used, and multiband filters (bandpass for example) estimations are derived from the lowpass design formulas.

Frequency domain specifications: Band edges (\(f\)) normalized by sample frequency, band amplitude (\(a\)), size of \(f\) is 2*sizeof(\(a\))-2, and maximum allowable deviation between the frequency response of the output filter and its band amplitude for each band (\(dev\)), specifying the passband ripple and the stopband attenuation.

Preprocess: If \(a\) value is not 0, divide each \(dev\) by the corresponding \(a\), so to get the relative deviation.

Scale Passband

This is to normalize the coefficients so that the magnitude response of the filter at the center of the passband is 1 (0 dB).