Chapter 13 designed IIR filters by transforming analog prototypes. This chapter designs FIR filters(有限脈衝響應濾波器) directly in discrete time. The simplest idea: start from a desired (usually ideal) frequency response $H_d(e^{j\omega})$ and find the best finite-length impulse response $h_t[n]$ that approximates it.第 13 章是把類比原型做轉換來設計 IIR 濾波器。本章則直接在離散時間裡設計 FIR 濾波器(有限脈衝響應濾波器)。最簡單的想法是:從一個想要的(通常是理想的)頻率響應 $H_d(e^{j\omega})$ 出發,找出能逼近它的最佳有限長度脈衝響應 $h_t[n]$。第 13 章ではアナログプロトタイプを変換して IIR フィルタを設計した。本章では離散時間で直接 FIR フィルタ(有限インパルス応答フィルタ)を設計する。もっとも素朴な発想はこうである:望みの(たいていは理想の)周波数応答 $H_d(e^{j\omega})$ から出発し、それを近似する最良の有限長インパルス応答 $h_t[n]$ を見つける。
“Best” needs a criterion. The natural first choice is to minimize the Integral Squared Error(積分平方誤差,ISE) between the desired and the actual frequency responses:「最佳」需要一個準則。最自然的第一個選擇,是把想要的頻率響應與實際頻率響應之間的積分平方誤差(Integral Squared Error,ISE)最小化:「最良」には基準が要る。もっとも自然な第一の選択は、望みの周波数応答と実際の周波数応答との積分二乗誤差(Integral Squared Error、ISE)を最小にすることである:
The ideal impulse response is $h_d[n] = \mathrm{IDTFT}\{H_d(e^{j\omega})\}$, which is usually infinite-extent. By Parseval’s theorem(帕塞瓦爾定理), the frequency-domain error equals a time-domain error:理想脈衝響應是 $h_d[n] = \mathrm{IDTFT}\{H_d(e^{j\omega})\}$,它通常是無限長的。依帕塞瓦爾定理(Parseval 定理),頻域裡的誤差等於時域裡的誤差:理想インパルス応答は $h_d[n] = \mathrm{IDTFT}\{H_d(e^{j\omega})\}$ であり、ふつう無限に広がる。パーセバルの定理により、周波数領域の誤差は時間領域の誤差に等しい:
Now constrain $h_t[n]$ to exist only for $n = -M,\dots,M$ (length $2M+1$). Split the sum:現在限制 $h_t[n]$ 只在 $n = -M,\dots,M$ 上存在(長度 $2M+1$)。把這個和式拆開:ここで $h_t[n]$ が $n = -M,\dots,M$ でのみ存在するよう制約する(長さ $2M+1$)。和を分割する:
The second term is fixed; the first is zeroed by simply copying $h_d[n]$ inside the support. So the minimum mean-squared-error FIR approximation of length $2M+1$ is the truncated IDTFT(截斷的反離散時間傅立葉變換):第二項是固定的;第一項只要在支撐範圍內直接照抄 $h_d[n]$ 就會歸零。所以長度 $2M+1$ 的最小均方誤差 FIR 逼近,就是截斷的 IDTFT(截斷的反離散時間傅立葉變換):第二項は固定である。第一項は台の内側で $h_d[n]$ をそのまま写すだけでゼロになる。したがって長さ $2M+1$ の最小平均二乗誤差 FIR 近似は、打ち切った IDTFT(逆離散時間フーリエ変換)である:
The truncated $h_t[n]$ is symmetric around $n=0$, hence noncausal. Make it causal(因果) by delaying $M$ samples:截斷後的 $h_t[n]$ 對 $n=0$ 對稱,因此是非因果的。延遲 $M$ 個樣本,就讓它成為因果的:打ち切った $h_t[n]$ は $n=0$ について対称なので非因果である。$M$ 標本遅らせて因果にする:
Recall (from the Fourier-domain chapter) the ideal lowpass filter(理想低通濾波器) with cutoff $\omega_c$:回想一下(傅立葉域那一章)截止頻率為 $\omega_c$ 的理想低通濾波器:(フーリエ領域の章から)遮断周波数 $\omega_c$ の理想低域通過フィルタを思い出そう:
The sinc-shaped $h_{LP}[n]$ extends from $-\infty$ to $\infty$ and decays only like $1/n$ — it can never be realized exactly. Applying the recipe of §14.1:sinc 形狀的 $h_{LP}[n]$ 從 $-\infty$ 延伸到 $\infty$,而且衰減只有 $1/n$ 那麼慢——它永遠無法被精確實現。把 §14.1 的配方套上去:sinc 形の $h_{LP}[n]$ は $-\infty$ から $\infty$ まで広がり、減衰は $1/n$ 程度でしかない —— 厳密に実現することはできない。§14.1 の処方を当てはめると:
(at $n = M$ the value is $\omega_c/\pi$ by the limit). The shift $n \to n-M$ is the causal delay.(在 $n = M$ 處,取極限其值為 $\omega_c/\pi$)。位移 $n \to n-M$ 就是那個讓它成為因果的延遲。($n = M$ では極限をとって値は $\omega_c/\pi$ である。)シフト $n \to n-M$ が因果にするための遅延である。
Fig. 14-1 shows the whole pipeline for $\omega_c = 0.3\pi$, $M = 12$: take the ideal sinc, keep $2M+1 = 25$ central samples, shift right by $M$, then look at the magnitude response.圖 14-1 把 $\omega_c = 0.3\pi$、$M = 12$ 的整條流程畫了出來:取理想 sinc,保留中央 $2M+1 = 25$ 個樣本,向右位移 $M$,然後看它的大小響應。図 14-1 は $\omega_c = 0.3\pi$、$M = 12$ の場合の流れ全体を示している:理想 sinc をとり、中央の $2M+1 = 25$ 標本を残し、右へ $M$ だけシフトし、そのうえで振幅応答を見る。
Plotting $|H_t(e^{j\omega})|$ for two lengths (25 and 129 points) reveals the Gibbs phenomenon(吉布斯現象): oscillatory ripples that pile up near the band edge, with a peak overshoot of about 9% of the discontinuity size.把兩種長度(25 點與 129 點)的 $|H_t(e^{j\omega})|$ 畫出來,就看得見Gibbs 現象:在頻帶邊緣堆積起來的振盪漣波,其尖峰過衝約為不連續跳躍量的 9%。二つの長さ(25 点と 129 点)について $|H_t(e^{j\omega})|$ を描くと、ギブス現象が見えてくる:帯域端に積み重なる振動的なリップルであり、そのピークのオーバーシュートは不連続の跳び幅のおよそ 9% である。
Truncation of $h_d[n]$ to $2M+1$ points is multiplication by a rectangular window(矩形窗):把 $h_d[n]$ 截斷成 $2M+1$ 點,就是乘上一個矩形窗:$h_d[n]$ を $2M+1$ 点に打ち切ることは、矩形窓を掛けることである:
Multiplication in the time domain is (periodic) convolution in the frequency domain(頻域摺積) — the modulation/windowing theorem:時域裡的相乘,就是頻域裡的(週期)摺積——也就是調變/加窗定理:時間領域の掛け算は、周波数領域の(周期)畳み込みである —— 変調(窓かけ)定理:
So the frequency response of the truncated filter is the ideal brick wall smeared by the DTFT of the rectangular window, which is the periodic sinc(週期 sinc / Dirichlet 核):所以截斷後濾波器的頻率響應,就是理想磚牆被矩形窗的 DTFT 抹開的結果,而那個 DTFT 就是週期 sinc(Dirichlet 核):したがって打ち切ったフィルタの周波数応答は、理想のレンガ壁が矩形窓の DTFT によってにじまされたものであり、その DTFT が周期 sinc(ディリクレ核)である:
As the mainlobe slides across the ideal discontinuity at $\omega_c$, the running integral of the sidelobes produces the ripples: in the passband the result oscillates around 1, in the transition it rolls off across the mainlobe width, and in the stopband it oscillates around 0. This is exactly the “type of approximation obtained at a discontinuity of an ideal frequency response” pictured on the slides.當主瓣滑過 $\omega_c$ 處的理想不連續點時,旁瓣的累積積分就製造出漣波:在通帶裡結果繞著 1 振盪,在過渡帶裡它在主瓣寬度上滾降,在阻帶裡則繞著 0 振盪。這正是投影片上畫的「理想頻率響應在不連續處所得到的那種逼近」。主ローブが $\omega_c$ の理想的な不連続点を横切っていくとき、サイドローブの積分の積み重ねがリップルを生む:通過帯域では結果が 1 のまわりで振動し、遷移帯域では主ローブ幅のあいだに落ちていき、阻止帯域では 0 のまわりで振動する。これがスライドに描かれた「理想周波数応答の不連続点で得られる近似の様子」そのものである。
Since the rectangular window’s $-13$ dB sidelobes give only ~$-21$ dB stopband ripple, we trade mainlobe width for lower sidelobes by using tapered windows(漸變窗). With the symmetric convention $-M \le n \le M$ (length $2M+1$), the slides list:既然矩形窗 $-13$ dB 的旁瓣只能換到約 $-21$ dB 的阻帶漣波,我們就改用漸變窗,拿主瓣寬度去換更低的旁瓣。採用對稱慣例 $-M \le n \le M$(長度 $2M+1$),投影片列出:矩形窓の $-13$ dB のサイドローブでは阻止帯域リップルが約 $-21$ dB にしかならないので、先細りの窓を使って主ローブ幅をサイドローブの低さと交換する。対称な規約 $-M \le n \le M$(長さ $2M+1$)のもとで、スライドは次を挙げている:
Qualitatively (matching the slide annotations): rectangular has big sidelobes; Hann has a double-width mainlobe but much lower sidelobes; Hamming has a reduced first sidelobe (the 0.54/0.46 split is tuned to partially cancel it); Blackman has a triple-width mainlobe with the lowest sidelobes of the four. The Bartlett(三角窗)window $w[n] = 1 - |n|/M$ also appears in the comparison table.定性地說(對照投影片上的註記):矩形窗有很大的旁瓣;Hann 的主瓣寬度加倍,但旁瓣低得多;Hamming 則把第一旁瓣壓下來(0.54/0.46 的拆法正是調來部分抵消它的);Blackman 的主瓣寬度變成三倍,四者之中旁瓣最低。比較表裡還會出現 Bartlett(三角窗)$w[n] = 1 - |n|/M$。定性的に言えば(スライドの注記に対応して)、矩形窓はサイドローブが大きい。Hann は主ローブ幅が二倍になるがサイドローブははるかに低い。Hamming は第一サイドローブが抑えられている(0.54/0.46 という分け方はそれを部分的に打ち消すよう調整されている)。Blackman は主ローブ幅が三倍で、四つのなかでもっともサイドローブが低い。比較表には Bartlett(三角窓)$w[n] = 1 - |n|/M$ も現れる。
The standard table (Oppenheim & Schafer Table 7.2, reproduced on slide 18) — here $M$ is the filter order (window length $M+1$):標準表格(Oppenheim & Schafer 表 7.2,投影片第 18 頁重印)——這裡的 $M$ 是濾波器階數(視窗長度 $M+1$):標準的な表(Oppenheim & Schafer 表 7.2、スライド 18 枚目に再掲)—— ここでの $M$ はフィルタ次数である(窓長は $M+1$):
| Type of window視窗種類窓の種類 | Peak sidelobe amplitude (relative, dB)最大旁瓣振幅(相對,dB)最大サイドローブ振幅(相対、dB) | Approx. mainlobe width主瓣寬度(約)主ローブ幅(概算) | Peak approximation error $20\log_{10}\delta$ (dB)最大逼近誤差 $20\log_{10}\delta$(dB)最大近似誤差 $20\log_{10}\delta$(dB) | Equivalent Kaiser $\beta$等效的 Kaiser $\beta$等価なカイザーの $\beta$ | Transition width of equiv. Kaiser等效 Kaiser 的過渡帶寬度等価なカイザー窓の遷移幅 |
|---|---|---|---|---|---|
| Rectangular矩形窗矩形窓 | −13 | $4\pi/(M+1)$ | −21 | 0 | $1.81\pi/M$ |
| BartlettBartlett(三角窗)Bartlett(三角窓) | −25 | $8\pi/M$ | −25 | 1.33 | $2.37\pi/M$ |
| HannHann 窗Hann 窓 | −31 | $8\pi/M$ | −44 | 3.86 | $5.01\pi/M$ |
| HammingHamming 窗Hamming 窓 | −41 | $8\pi/M$ | −53 | 4.86 | $6.27\pi/M$ |
| BlackmanBlackman 窗Blackman 窓 | −57 | $12\pi/M$ | −74 | 7.04 | $9.19\pi/M$ |
The fixed windows offer only discrete main-sidelobe trade-offs. The Kaiser window(凱瑟窗) is parametric: a continuous knob $\beta$ sweeps the trade-off.固定形狀的視窗,只提供離散的主瓣—旁瓣取捨。Kaiser 視窗(凱瑟窗)則是帶參數的:一個連續的旋鈕 $\beta$ 就能掃過整條取捨曲線。形の決まった窓は離散的な主ローブ・サイドローブのトレードオフしか与えない。カイザー窓はパラメトリックである:連続したつまみ $\beta$ がトレードオフを掃いていく。
where $I_0(\cdot)$ is the modified zero-order Bessel function(零階修正貝索函數). $\beta = 0$ gives the rectangular window; larger $\beta$ tapers harder ⇒ lower sidelobes, wider mainlobe.其中 $I_0(\cdot)$ 是零階修正貝索函數。$\beta = 0$ 給出矩形窗;$\beta$ 越大漸變越劇烈 ⇒ 旁瓣更低、主瓣更寬。ここで $I_0(\cdot)$ は0 次の変形ベッセル関数である。$\beta = 0$ は矩形窓を与え、$\beta$ が大きいほど強く先細りになる ⇒ サイドローブは低く、主ローブは広くなる。
Kaiser also gave empirical design formulas. Given the required minimum stopband attenuation $\alpha$ in dB (with $\alpha = -20\log_{10}\delta$) and the transition width $\Delta\omega = \omega_s - \omega_p$:Kaiser 還給了經驗設計公式。給定所需的最小阻帶衰減 $\alpha$(以 dB 計,其中 $\alpha = -20\log_{10}\delta$)以及過渡帶寬度 $\Delta\omega = \omega_s - \omega_p$:カイザーは経験的な設計式も与えた。必要な最小阻止帯域減衰量 $\alpha$(dB 単位、ただし $\alpha = -20\log_{10}\delta$)と遷移幅 $\Delta\omega = \omega_s - \omega_p$ が与えられたとき:
(The slides round the coefficients to $0.11$, $0.58$, $0.08$ and use $2.3$; Oppenheim & Schafer’s constant is $2.285$ — same formula to slide precision.) Note that for $\alpha < 21$ dB the Kaiser window degenerates to rectangular: you cannot ask for less ripple than Gibbs gives for free.(投影片把係數四捨五入成 $0.11$、$0.58$、$0.08$,並取 $2.3$;Oppenheim & Schafer 的常數是 $2.285$——在投影片的精度下是同一條公式。)注意當 $\alpha < 21$ dB 時,Kaiser 視窗會退化成矩形窗:你沒辦法要求比 Gibbs 免費給你的還小的漣波。(スライドは係数を $0.11$、$0.58$、$0.08$ に丸め、$2.3$ を使っている。Oppenheim & Schafer の定数は $2.285$ であり —— スライドの精度では同じ式である。)$\alpha < 21$ dB ではカイザー窓が矩形窓に退化することに注意せよ:ギブスがただでくれるより小さいリップルを要求することはできない。
kaiser(N,beta) generates the window; kaiserord turns a spec $\{\omega_p,\omega_s,\delta_p,\delta_s\}$ directly into [n, Wn, beta, ftype] for fir1. The generic windowed design is one line: h = fir1(n, Wn, kaiser(n+1, beta)). For other windows use hann, hamming, blackman with fir1(n, Wn, window).kaiser(N,beta) 產生視窗;kaiserord 把規格 $\{\omega_p,\omega_s,\delta_p,\delta_s\}$ 直接轉成給 fir1 用的 [n, Wn, beta, ftype]。一般的加窗設計只要一行:h = fir1(n, Wn, kaiser(n+1, beta))。其他視窗就用 hann、hamming、blackman 搭配 fir1(n, Wn, window)。kaiser(N,beta) が窓を生成する。kaiserord は仕様 $\{\omega_p,\omega_s,\delta_p,\delta_s\}$ をそのまま fir1 用の [n, Wn, beta, ftype] へ変換する。一般の窓関数法設計は一行である:h = fir1(n, Wn, kaiser(n+1, beta))。他の窓を使うなら hann、hamming、blackman を fir1(n, Wn, window) と組み合わせる。
No specific transition/ripple requirements are given, so we compromise with a Hamming window.題目沒有給定過渡帶/漣波的具體要求,所以我們折衷採用 Hamming 窗。遷移幅やリップルの具体的な要求は与えられていないので、折衷として Hamming 窓を使う。
The ideal LPF has a pure-real frequency response: $\theta(\omega) = 0$, $H(e^{j\omega}) = |H(e^{j\omega})|$. Pure-real responses can be added and subtracted like numbers, so piecewise-constant ideal responses are built from ideal lowpass blocks. Example — an ideal highpass(高通):理想低通濾波器的頻率響應是純實數的:$\theta(\omega) = 0$、$H(e^{j\omega}) = |H(e^{j\omega})|$。純實數的響應可以像數字一樣相加相減,所以分段常數的理想響應,都能用理想低通積木拼出來。舉例——一個理想高通:理想低域通過フィルタの周波数応答は純実数である:$\theta(\omega) = 0$、$H(e^{j\omega}) = |H(e^{j\omega})|$。純実数の応答は数のように足し引きできるので、区分的に一定な理想応答は理想低域通過のブロックから組み立てられる。たとえば理想高域通過は:
since $\delta[n] \leftrightarrow H(e^{j\omega}) = 1$ (allpass). The same arithmetic gives bandpass and bandstop responses (Exercise 5).因為 $\delta[n] \leftrightarrow H(e^{j\omega}) = 1$(全通)。同樣的加減運算也給得出帶通與帶阻的響應(習題 5)。$\delta[n] \leftrightarrow H(e^{j\omega}) = 1$(全域通過)だからである。同じ算術で帯域通過と帯域阻止の応答も得られる(演習 5)。
Window methods give you no independent control of passband vs. stopband ripple:視窗法不讓你獨立控制通帶漣波與阻帶漣波:窓関数法では、通過帯域リップルと阻止帯域リップルを独立に制御できない:
Since the worst-case error of a windowed design is concentrated at the band edges, a better criterion is minimax(極大極小): minimize the maximum weighted error over passband and stopband. The optimal solution is equiripple(等漣波) — the error oscillates with equal peaks (alternation theorem), and the Parks–McClellan algorithm finds it by iterative Chebyshev approximation (Remez exchange). Every ripple is pushed down to exactly the spec, no accuracy is wasted, so for the same spec the equiripple filter needs fewer taps than any windowed design.既然加窗設計的最壞誤差集中在頻帶邊緣,更好的準則就是極大極小(minimax):把通帶與阻帶上加權誤差的最大值最小化。最佳解是等漣波的——誤差以等高的峰值振盪(交錯定理),而Parks–McClellan 演算法用疊代的 Chebyshev 逼近(Remez 交換法)把它找出來。每一個漣波都被壓到剛好貼著規格,沒有任何精度被浪費,所以在同一份規格下,等漣波濾波器需要的抽頭數比任何加窗設計都少。窓による設計の最悪誤差は帯域端に集中するので、より良い基準はミニマックスである:通過帯域と阻止帯域にわたる重み付き誤差の最大値を最小にする。最適解は等リップルである —— 誤差は等しい高さのピークで振動し(交代定理)、Parks–McClellan アルゴリズムが反復的なチェビシェフ近似(Remez 交換法)でそれを見つける。どのリップルもちょうど仕様に貼りつくまで押し下げられ、精度が無駄にならないので、同じ仕様なら等リップルフィルタはどんな窓設計よりも少ないタップで済む。
[n,fo,ao,w] = firpmord([fp fs], [1 0], [dp ds]) estimates the order, then h = firpm(n, fo, ao, w) runs Parks–McClellan (formerly remez). In Python: scipy.signal.remez.[n,fo,ao,w] = firpmord([fp fs], [1 0], [dp ds]) 估算階數,接著 h = firpm(n, fo, ao, w) 執行 Parks–McClellan(舊名 remez)。在 Python 裡則是 scipy.signal.remez。[n,fo,ao,w] = firpmord([fp fs], [1 0], [dp ds]) が次数を見積もり、続いて h = firpm(n, fo, ao, w) が Parks–McClellan を実行する(旧名は remez)。Python では scipy.signal.remez である。
The slides close with a benchmark spec — passband edge $0.22\pi$, stopband edge $0.29\pi$, passband gain $0$ to $-1$ dB, stopband $\le -40$ dB — designed with every method (O&S Table 7.3):投影片以一份基準規格作結——通帶邊界 $0.22\pi$、阻帶邊界 $0.29\pi$、通帶增益 $0$ 到 $-1$ dB、阻帶 $\le -40$ dB——並用每一種方法都設計了一遍(O&S 表 7.3):スライドはベンチマーク仕様で締めくくられる —— 通過帯域端 $0.22\pi$、阻止帯域端 $0.29\pi$、通過帯域利得 $0$ から $-1$ dB、阻止帯域 $\le -40$ dB —— をあらゆる方法で設計した結果である(O&S 表 7.3):
| Filter design濾波器設計法フィルタ設計法 | Order階數次数 | Type型態型式 | Multiplications (symmetric structure)乘法次數(對稱結構)乗算回数(対称構造) |
|---|---|---|---|
| ButterworthButterworth 濾波器Butterworth フィルタ | 18 | IIRIIR 型IIR 型 | — |
| Chebyshev IChebyshev 一型Chebyshev I 型 | 8 | IIRIIR 型IIR 型 | — |
| Chebyshev IIChebyshev 二型Chebyshev II 型 | 8 | IIRIIR 型IIR 型 | — |
| Elliptic橢圓楕円 | 5 | IIRIIR 型IIR 型 | 8 |
| Kaiser (window)Kaiser(視窗法)Kaiser(窓関数法) | 63 | FIRFIR 型FIR 型 | 32 (linear phase)32(線性相位)32(線形位相) |
| Parks–McClellanParks–McClellan 法Parks–McClellan 法 | 44 | FIRFIR 型FIR 型 | 23 (linear phase)23(線性相位)23(線形位相) |
1) $\omega_c = 2\pi f_c/f_s$. 2) $h_d[n] = \mathrm{IDTFT}\{H_d\}$ (sinc for LPF). 3) Pick window shape from ripple spec, length from transition spec. 4) $h[n] = h_d[n]w[n]$. 5) Delay by $M$ for causality (linear phase).1) $\omega_c = 2\pi f_c/f_s$。2) $h_d[n] = \mathrm{IDTFT}\{H_d\}$(低通就是 sinc)。3) 由漣波規格挑視窗形狀,由過渡帶規格挑長度。4) $h[n] = h_d[n]w[n]$。5) 延遲 $M$ 以取得因果性(線性相位)。1) $\omega_c = 2\pi f_c/f_s$。2) $h_d[n] = \mathrm{IDTFT}\{H_d\}$(低域通過なら sinc)。3) リップル仕様から窓形状を、遷移幅仕様から長さを選ぶ。4) $h[n] = h_d[n]w[n]$。5) 因果性のために $M$ だけ遅らせる(線形位相)。
By Parseval, ISE-optimal length-$(2M+1)$ FIR = plain truncation of $h_d[n]$ to $|n| \le M$. Optimal in energy, terrible in worst case.依帕塞瓦爾定理,ISE 最佳的長度 $(2M+1)$ FIR =把 $h_d[n]$ 直接截斷到 $|n| \le M$。在能量上最佳,在最壞情況下慘不忍睹。パーセバルの定理により、ISE 最適な長さ $(2M+1)$ の FIR = $h_d[n]$ を $|n| \le M$ へ素朴に打ち切ったもの。エネルギーでは最適だが、最悪値ではひどい。
Truncation = × rectangular window = frequency-domain convolution with a periodic sinc. ~9% ears at discontinuities; longer filters narrow the ears but never shorten them. Not minimax-optimal.截斷=乘上矩形窗=在頻域與週期 sinc 做摺積。不連續處長出約 9% 的耳朵;加長濾波器只讓耳朵變窄,永遠不會變矮。在極大極小意義下並非最佳。打ち切り=矩形窓を掛けること=周波数領域で周期 sinc と畳み込むこと。不連続点に約 9% の耳が立つ。フィルタを長くしても耳は細くなるだけで低くはならない。ミニマックス最適ではない。
Mainlobe width ($\propto 1/L$) → transition band. Sidelobe height (shape-determined, length-invariant) → ripple. Rect −21 dB, Hann −44, Hamming −53, Blackman −74 dB peak error.主瓣寬度($\propto 1/L$)→ 過渡帶。旁瓣高度(由形狀決定,與長度無關)→ 漣波。最大誤差:矩形 −21 dB、Hann −44、Hamming −53、Blackman −74 dB。主ローブ幅($\propto 1/L$)→ 遷移帯域。サイドローブの高さ(形状で決まり長さに依らない)→ リップル。最大誤差は矩形 −21 dB、Hann −44、Hamming −53、Blackman −74 dB。
$w[n] = I_0\bigl(\beta\sqrt{1-(n/M)^2}\bigr)/I_0(\beta)$; $\beta$ from $\alpha$ (piecewise empirical fit), order $N \approx (\alpha-8)/(2.3\,\Delta\omega)$. One continuous knob replaces the window zoo.$w[n] = I_0\bigl(\beta\sqrt{1-(n/M)^2}\bigr)/I_0(\beta)$;$\beta$ 由 $\alpha$ 決定(分段的經驗配適),階數 $N \approx (\alpha-8)/(2.3\,\Delta\omega)$。一個連續的旋鈕就取代了一整座視窗動物園。$w[n] = I_0\bigl(\beta\sqrt{1-(n/M)^2}\bigr)/I_0(\beta)$。$\beta$ は $\alpha$ から決まり(区分的な経験式)、次数は $N \approx (\alpha-8)/(2.3\,\Delta\omega)$。連続したつまみ一つが窓の動物園を置き換える。
Parks–McClellan minimizes the max error ⇒ equiripple, fewest taps (44 vs Kaiser 63 on the benchmark). IIR (elliptic order 5) is still far cheaper, but FIR gives exact linear phase and unconditional stability.Parks–McClellan 把最大誤差最小化 ⇒ 等漣波、抽頭數最少(基準題上是 44,Kaiser 則要 63)。IIR(橢圓 5 階)仍然便宜得多,但 FIR 給得出精確的線性相位與無條件的穩定性。Parks–McClellan は最大誤差を最小にする ⇒ 等リップルで、タップ数が最少(ベンチマークでは 44、カイザーは 63)。IIR(楕円の 5 次)はなお圧倒的に安上がりだが、FIR は厳密な線形位相と無条件の安定性を与える。
Problem: A desired frequency response $H_d(e^{j\omega})$ has ideal impulse response $h_d[n]$ (infinite extent). We seek the FIR filter $h_t[n]$, nonzero only for $-M \le n \le M$, that minimizes $\phi = \frac{1}{2\pi}\int_{-\pi}^{\pi} |H_d(e^{j\omega}) - H_t(e^{j\omega})|^2 d\omega$. (a) Show that the minimizer is $h_t[n] = h_d[n]$ for $|n| \le M$. (b) Give the residual (minimum) error. (c) Explain why this “best” filter can still have a large error at a single frequency.問題:某個想要的頻率響應 $H_d(e^{j\omega})$,其理想脈衝響應是 $h_d[n]$(無限長)。我們要找只在 $-M \le n \le M$ 上非零的 FIR 濾波器 $h_t[n]$,使 $\phi = \frac{1}{2\pi}\int_{-\pi}^{\pi} |H_d(e^{j\omega}) - H_t(e^{j\omega})|^2 d\omega$ 最小。(a) 證明最小解是在 $|n| \le M$ 上取 $h_t[n] = h_d[n]$。(b) 給出剩餘的(最小)誤差。(c) 說明為什麼這個「最佳」濾波器在單一頻率上仍可能有很大的誤差。問題:ある望みの周波数応答 $H_d(e^{j\omega})$ の理想インパルス応答は $h_d[n]$ である(無限に広がる)。$-M \le n \le M$ でのみ非零な FIR フィルタ $h_t[n]$ のうち、$\phi = \frac{1}{2\pi}\int_{-\pi}^{\pi} |H_d(e^{j\omega}) - H_t(e^{j\omega})|^2 d\omega$ を最小にするものを求めたい。(a) 最小解が $|n| \le M$ において $h_t[n] = h_d[n]$ となることを示せ。(b) 残る(最小の)誤差を与えよ。(c) この「最良」のフィルタが、ある一つの周波数では依然として大きな誤差をもちうる理由を説明せよ。
(a) By Parseval’s theorem the cost equals the time-domain energy of the error:(a) 依帕塞瓦爾定理,這個代價等於誤差在時域的能量:(a) パーセバルの定理により、このコストは誤差の時間領域エネルギーに等しい:
$$\phi = \sum_{n=-\infty}^{\infty}\bigl|h_d[n]-h_t[n]\bigr|^2 = \sum_{n=-M}^{M}\bigl|h_d[n]-h_t[n]\bigr|^2 + \sum_{|n|>M}\bigl|h_d[n]\bigr|^2 .$$Each term is nonnegative. The second sum does not depend on $h_t[n]$ at all (there $h_t[n]=0$ by constraint). The first sum is minimized — made exactly zero — by choosing $h_t[n] = h_d[n]$ on $-M \le n \le M$. Hence truncation is optimal.每一項都非負。第二個和式完全不依賴 $h_t[n]$(在那裡依限制有 $h_t[n]=0$)。第一個和式則在 $-M \le n \le M$ 上取 $h_t[n] = h_d[n]$ 時被最小化——而且剛好歸零。因此截斷是最佳的。各項は非負である。第二の和は $h_t[n]$ にまったく依存しない(そこでは制約により $h_t[n]=0$ である)。第一の和は $-M \le n \le M$ 上で $h_t[n] = h_d[n]$ と選ぶことで最小化され —— ちょうどゼロになる。よって打ち切りが最適である。
(b) The residual error is the energy of the discarded tail:(b) 剩餘誤差就是被丟掉的那條尾巴的能量:(b) 残る誤差は、捨てた裾のエネルギーである:
$$\phi_{\min} = \sum_{n < -M,\; n > M}\bigl|h_d[n]\bigr|^2 .$$For the ideal LPF, $h_d[n] \sim 1/n$, so $\phi_{\min} \sim 1/M$: it decays, but slowly.對理想低通濾波器而言 $h_d[n] \sim 1/n$,所以 $\phi_{\min} \sim 1/M$:它會下降,但下降得很慢。理想低域通過フィルタでは $h_d[n] \sim 1/n$ なので $\phi_{\min} \sim 1/M$ である:減りはするが、ゆっくりである。
(c) The ISE is an integral criterion: it penalizes total error energy, not peak error. The error can concentrate into ever-narrower spikes near a discontinuity (Gibbs ears) whose energy → small while their height stays ≈ 9% of the jump. Minimizing ISE therefore says nothing about the worst-case (minimax) error.(c) ISE 是一個積分準則:它懲罰的是誤差的總能量,不是尖峰誤差。誤差可以集中成不連續點附近越來越窄的尖刺(Gibbs 耳朵),其能量 → 很小,但高度仍停在跳躍量的約 9%。所以把 ISE 最小化,對最壞情況(極大極小)誤差什麼也沒說。(c) ISE は積分的な基準である:罰するのは誤差の総エネルギーであって、ピーク誤差ではない。誤差は不連続点の近くでどんどん細いスパイク(ギブスの耳)に集中でき、そのエネルギーは → 小さくなる一方で、高さは跳び幅の約 9% のままである。したがって ISE を最小にしても、最悪値(ミニマックス)誤差については何も言えない。
Problem: A student designs a lowpass FIR by truncating the ideal sinc to 25 points and observes ~9% overshoot near the cutoff. To fix it, the student increases the length to 129 points. (a) What happens to the overshoot and why? (b) Express the truncated response $H_t(e^{j\omega})$ in terms of $H_d$ and the window spectrum. (c) Which property of $W_R(e^{j\omega})$ controls the transition width, and how does it scale with length? (d) What should the student change to reduce the overshoot?問題:有位學生把理想 sinc 截斷成 25 點來設計低通 FIR,發現截止頻率附近有約 9% 的過衝。為了修掉它,他把長度加到 129 點。(a) 過衝會怎麼變?為什麼?(b) 用 $H_d$ 與視窗頻譜把截斷後的響應 $H_t(e^{j\omega})$ 表示出來。(c) $W_R(e^{j\omega})$ 的哪一項性質控制過渡帶寬度?它如何隨長度縮放?(d) 這位學生應該改什麼,才能把過衝壓小?問題:ある学生が理想 sinc を 25 点に打ち切って低域通過 FIR を設計し、遮断周波数付近に約 9% のオーバーシュートを見つけた。直そうとして長さを 129 点に増やした。(a) オーバーシュートはどうなるか、またなぜか。(b) 打ち切った応答 $H_t(e^{j\omega})$ を $H_d$ と窓のスペクトルで表せ。(c) $W_R(e^{j\omega})$ のどの性質が遷移幅を決め、それは長さとともにどうスケールするか。(d) オーバーシュートを減らすには、この学生は何を変えるべきか。
(a) The overshoot height stays ≈ 9% — the ears only get narrower. The relative sidelobe level of the rectangular window (−13 dB) is essentially independent of its length, and the overshoot is set by the integrated sidelobes, not by $N$.(a) 過衝高度仍停在約 9%——耳朵只是變窄。矩形窗的相對旁瓣位準(−13 dB)基本上與長度無關,而過衝是由旁瓣的積分決定,不是由 $N$ 決定。(a) オーバーシュートの高さは約 9% のままで、耳が細くなるだけである。矩形窓の相対サイドローブ準位(−13 dB)は長さにほとんど依存せず、オーバーシュートはサイドローブの積分で決まるのであって $N$ で決まるのではない。
(b) Truncation is multiplication by $w_R[n]$, so by the modulation theorem(b) 截斷就是乘上 $w_R[n]$,所以依調變定理(b) 打ち切りは $w_R[n]$ を掛けることなので、変調定理により
$$H_t(e^{j\omega}) = \frac{1}{2\pi}\int_{-\pi}^{\pi} H_d(e^{j\theta})\, W_R\!\left(e^{j(\omega-\theta)}\right) d\theta , \qquad W_R(e^{j\omega}) = \frac{\sin\bigl((2M+1)\omega/2\bigr)}{\sin(\omega/2)} .$$(c) The mainlobe width, $4\pi/(2M+1)$ between zero crossings: it shrinks as $1/$length, so the transition band sharpens as the filter lengthens.(c) 主瓣寬度,也就是零交越之間的 $4\pi/(2M+1)$:它以 $1/$長度 的方式縮小,所以濾波器越長,過渡帶就越陡。(c) 主ローブ幅、すなわち零交差のあいだの $4\pi/(2M+1)$ である。これは $1/$長さ で縮むので、フィルタが長いほど遷移帯域は急になる。
(d) Change the window shape, not (only) the length: use a tapered window (Hann/Hamming/Blackman) or a Kaiser window with $\beta$ chosen from the required attenuation. Lower sidelobes ⇒ smaller ripples/overshoot, at the price of a wider mainlobe (longer filter for the same transition width).(d) 要改的是視窗的形狀,而不是(只有)長度:改用漸變窗(Hann/Hamming/Blackman),或用 $\beta$ 由所需衰減決定的 Kaiser 視窗。旁瓣更低 ⇒ 漣波與過衝更小,代價是主瓣更寬(同樣的過渡帶寬度要用更長的濾波器)。(d) 変えるべきは窓の形状であって、長さ(だけ)ではない:先細りの窓(Hann/Hamming/Blackman)を使うか、必要な減衰量から $\beta$ を決めたカイザー窓を使う。サイドローブが低い ⇒ リップルとオーバーシュートは小さくなるが、代わりに主ローブが広くなる(同じ遷移幅ならフィルタは長くなる)。
Problem: Design a 33-point linear-phase FIR low-pass filter with cutoff 1 kHz for a system sampled at 8 kHz, using a Hann window. (a) Find $\omega_c$. (b) Write the closed-form $h[n]$ (noncausal form) and state the causal shift. (c) Using the comparison table, estimate the stopband attenuation and the transition width. (d) What is the group delay in samples and in milliseconds?問題:為一個以 8 kHz 取樣的系統,用 Hann 視窗設計一個 33 點、線性相位、截止頻率 1 kHz 的 FIR 低通濾波器。(a) 求 $\omega_c$。(b) 寫出閉合形式的 $h[n]$(非因果形式),並說明因果位移。(c) 用比較表估計阻帶衰減與過渡帶寬度。(d) 群延遲是多少個樣本、多少毫秒?問題:標本化周波数 8 kHz のシステム向けに、Hann 窓を使って遮断周波数 1 kHz の 33 点線形位相 FIR 低域通過フィルタを設計せよ。(a) $\omega_c$ を求めよ。(b) 閉じた形の $h[n]$(非因果形)を書き、因果にするシフトを述べよ。(c) 比較表を使って阻止帯域減衰量と遷移幅を見積もれ。(d) 群遅延は何標本で、何ミリ秒か。
(a) $\displaystyle \omega_c = \frac{1000}{8000}\times 2\pi = 0.25\pi$ rad/sample.(a) $\displaystyle \omega_c = \frac{1000}{8000}\times 2\pi = 0.25\pi$ 弧度/樣本。(a) $\displaystyle \omega_c = \frac{1000}{8000}\times 2\pi = 0.25\pi$ rad/sample である。
(b) $N = 33 = 2M+1 \Rightarrow M = 16$. With the slide convention:(b) $N = 33 = 2M+1 \Rightarrow M = 16$。採用投影片的慣例:(b) $N = 33 = 2M+1 \Rightarrow M = 16$。スライドの規約に従うと:
$$h[n] = \frac{\sin 0.25\pi n}{\pi n}\left(0.5 + 0.5\cos\frac{2\pi n}{33}\right), \qquad -16 \le n \le 16,$$with $h[0] = \omega_c/\pi = 0.25$. Delay by $M = 16$ samples: $\hat h[n] = h[n-16]$, $0 \le n \le 32$.其中 $h[0] = \omega_c/\pi = 0.25$。延遲 $M = 16$ 個樣本:$\hat h[n] = h[n-16]$,$0 \le n \le 32$。ここで $h[0] = \omega_c/\pi = 0.25$ である。$M = 16$ 標本遅らせると $\hat h[n] = h[n-16]$、$0 \le n \le 32$ となる。
(c) Hann window: peak approximation error $\approx -44$ dB ⇒ stopband attenuation ≈ 44 dB (and passband ripple $\delta_p = \delta_s \approx 10^{-44/20} \approx 0.0063$). Transition width (table, order $M_{\text{ord}} = 32$): $\Delta\omega \approx 8\pi/32 = 0.25\pi$ rad/sample, i.e. about $0.25\pi/(2\pi)\times 8000 = 1$ kHz.(c) Hann 窗:最大逼近誤差 $\approx -44$ dB ⇒ 阻帶衰減約 44 dB(通帶漣波則為 $\delta_p = \delta_s \approx 10^{-44/20} \approx 0.0063$)。過渡帶寬度(查表,階數 $M_{\text{ord}} = 32$):$\Delta\omega \approx 8\pi/32 = 0.25\pi$ 弧度/樣本,也就是約 $0.25\pi/(2\pi)\times 8000 = 1$ kHz。(c) Hann 窓:最大近似誤差 $\approx -44$ dB ⇒ 阻止帯域減衰量は約 44 dB(通過帯域リップルは $\delta_p = \delta_s \approx 10^{-44/20} \approx 0.0063$)。遷移幅(表より、次数 $M_{\text{ord}} = 32$):$\Delta\omega \approx 8\pi/32 = 0.25\pi$ rad/sample、すなわち約 $0.25\pi/(2\pi)\times 8000 = 1$ kHz である。
(d) Linear phase with symmetric $h[n]$: group delay $= M = 16$ samples $= 16/8000 = 2$ ms.(d) 對稱的 $h[n]$ 給出線性相位:群延遲 $= M = 16$ 個樣本 $= 16/8000 = 2$ 毫秒。(d) 対称な $h[n]$ による線形位相:群遅延は $= M = 16$ 標本 $= 16/8000 = 2$ ms である。
Problem: A lowpass filter must satisfy: passband edge $\omega_p = 0.22\pi$, stopband edge $\omega_s = 0.29\pi$, minimum stopband attenuation $\alpha = 40$ dB. Using Kaiser’s empirical formulas, find (a) the ripple $\delta$, (b) the shape parameter $\beta$, (c) the required order $N$, and (d) the cutoff $\omega_c$ you would hand to the ideal-sinc prototype.問題:某個低通濾波器必須滿足:通帶邊界 $\omega_p = 0.22\pi$、阻帶邊界 $\omega_s = 0.29\pi$、最小阻帶衰減 $\alpha = 40$ dB。用 Kaiser 的經驗公式求 (a) 漣波 $\delta$、(b) 形狀參數 $\beta$、(c) 所需階數 $N$,以及 (d) 你會交給理想 sinc 原型的截止頻率 $\omega_c$。問題:ある低域通過フィルタは次を満たさなければならない:通過帯域端 $\omega_p = 0.22\pi$、阻止帯域端 $\omega_s = 0.29\pi$、最小阻止帯域減衰量 $\alpha = 40$ dB。カイザーの経験式を用いて、(a) リップル $\delta$、(b) 形状パラメータ $\beta$、(c) 必要な次数 $N$、(d) 理想 sinc プロトタイプに渡す遮断周波数 $\omega_c$ を求めよ。
(a) $\delta = 10^{-\alpha/20} = 10^{-2} = 0.01$ (window methods force $\delta_p = \delta_s = \delta$).(a) $\delta = 10^{-\alpha/20} = 10^{-2} = 0.01$(視窗法強制 $\delta_p = \delta_s = \delta$)。(a) $\delta = 10^{-\alpha/20} = 10^{-2} = 0.01$(窓関数法は $\delta_p = \delta_s = \delta$ を強制する)。
(b) $21 \le \alpha \le 50$, so(b) $21 \le \alpha \le 50$,所以(b) $21 \le \alpha \le 50$ なので
$$\beta = 0.5842\,(40-21)^{0.4} + 0.07886\,(40-21) = 0.5842(19)^{0.4} + 0.07886 \times 19 \approx 1.897 + 1.498 \approx 3.40 .$$(c) $\Delta\omega = \omega_s - \omega_p = 0.07\pi \approx 0.2199$ rad. Then(c) $\Delta\omega = \omega_s - \omega_p = 0.07\pi \approx 0.2199$ 弧度。於是(c) $\Delta\omega = \omega_s - \omega_p = 0.07\pi \approx 0.2199$ rad である。したがって
$$N \approx \frac{\alpha - 8}{2.3\,\Delta\omega} = \frac{32}{2.3 \times 0.2199} \approx 63.3 \;\Rightarrow\; N = 63 \text{ (order)},$$i.e. 64 taps — matching the “Kaiser: 63” row of Table 7.3 (the slides’ benchmark). (With O&S’s constant 2.285 the estimate is 63.7; tools like kaiserord round up and may return 64–65 taps.)也就是 64 個抽頭——與表 7.3「Kaiser:63」那一列(投影片的基準題)相符。(若用 O&S 的常數 2.285,估出來是 63.7;像 kaiserord 這類工具會向上取整,可能回傳 64–65 個抽頭。)すなわち 64 タップであり、表 7.3 の「Kaiser:63」の行(スライドのベンチマーク)と一致する。(O&S の定数 2.285 を使えば見積りは 63.7 である。kaiserord のようなツールは切り上げるので 64–65 タップを返すことがある。)
(d) Center the transition band: $\omega_c = (\omega_p + \omega_s)/2 = 0.255\pi$.(d) 把過渡帶置中:$\omega_c = (\omega_p + \omega_s)/2 = 0.255\pi$。(d) 遷移帯域の中央に置く:$\omega_c = (\omega_p + \omega_s)/2 = 0.255\pi$。
Problem: Using only ideal-lowpass building blocks $h_{LP}[n;\omega_c] = \sin(\omega_c n)/(\pi n)$ and the allpass $\delta[n]$, find the ideal impulse responses of (a) a highpass filter with cutoff $\omega_c$, (b) a bandpass filter with band $\omega_1 < |\omega| < \omega_2$, and (c) a bandstop filter that rejects $\omega_1 < |\omega| < \omega_2$. (d) State the property of the ideal responses that makes this arithmetic legal, and what you must not do before combining them.問題:只用理想低通的積木 $h_{LP}[n;\omega_c] = \sin(\omega_c n)/(\pi n)$ 與全通的 $\delta[n]$,求出 (a) 截止頻率為 $\omega_c$ 的高通濾波器、(b) 通帶為 $\omega_1 < |\omega| < \omega_2$ 的帶通濾波器,以及 (c) 阻掉 $\omega_1 < |\omega| < \omega_2$ 的帶阻濾波器的理想脈衝響應。(d) 說明理想響應的哪一項性質讓這種加減運算合法,以及在把它們組合起來之前你絕不能做什麼。問題:理想低域通過のブロック $h_{LP}[n;\omega_c] = \sin(\omega_c n)/(\pi n)$ と全域通過の $\delta[n]$ だけを使って、(a) 遮断周波数 $\omega_c$ の高域通過フィルタ、(b) 帯域が $\omega_1 < |\omega| < \omega_2$ の帯域通過フィルタ、(c) $\omega_1 < |\omega| < \omega_2$ を阻止する帯域阻止フィルタの理想インパルス応答を求めよ。(d) この算術を正当なものにしている理想応答の性質と、組み合わせる前にやってはいけないことを述べよ。
All ideal responses here are pure real (zero phase), so magnitudes add/subtract directly.這裡所有的理想響應都是純實數(零相位)的,所以大小響應可以直接相加相減。ここでの理想応答はすべて純実数(ゼロ位相)なので、振幅をそのまま足し引きできる。
(a) $H_{HP} = 1 - H_{LP}(\omega_c)$:
$$h_{HP}[n] = \delta[n] - \frac{\sin \omega_c n}{\pi n}$$(b) $H_{BP} = H_{LP}(\omega_2) - H_{LP}(\omega_1)$:
$$h_{BP}[n] = \frac{\sin \omega_2 n}{\pi n} - \frac{\sin \omega_1 n}{\pi n}$$(c) $H_{BS} = 1 - H_{BP}$:
$$h_{BS}[n] = \delta[n] - \frac{\sin \omega_2 n}{\pi n} + \frac{\sin \omega_1 n}{\pi n}$$(d) Legality rests on $\theta(\omega) = 0$ for every block, so that $H_1 \pm H_2$ manipulates the magnitudes themselves; with nonzero (e.g. different linear) phases, $|H_1 \pm H_2| \neq |H_1| \pm |H_2|$ and the brick walls would be destroyed. Therefore: do not apply the causal delay to the individual blocks first — combine the zero-phase responses, window the result, and delay once at the very end. (Windowing the combination with $w[n]$ then delaying by $M$ keeps everything consistent because all blocks share the same window and the same delay.)(d) 合法性建立在每一塊積木都有 $\theta(\omega) = 0$ 之上,這樣 $H_1 \pm H_2$ 操作到的才是大小響應本身;若相位不為零(例如各自帶著不同的線性相位),就會有 $|H_1 \pm H_2| \neq |H_1| \pm |H_2|$,磚牆也就毀了。所以:不要先對個別積木套上因果延遲——先把零相位的響應組合起來,對結果加窗,最後才一次延遲。(先用 $w[n]$ 對組合結果加窗、再延遲 $M$,一切都會一致,因為所有積木共用同一個視窗與同一個延遲。)(d) 正当性はどのブロックでも $\theta(\omega) = 0$ であることに依っており、それゆえ $H_1 \pm H_2$ は振幅そのものを操作する。位相が非零であれば(たとえばそれぞれ異なる線形位相をもてば)$|H_1 \pm H_2| \neq |H_1| \pm |H_2|$ となり、レンガ壁は壊れてしまう。したがって、個々のブロックに先に因果遅延を掛けてはいけない —— ゼロ位相の応答を組み合わせ、その結果に窓を掛け、最後に一度だけ遅らせる。(組み合わせた結果に $w[n]$ を掛けてから $M$ だけ遅らせれば、すべてのブロックが同じ窓と同じ遅延を共有するので整合が保たれる。)
kaiserord / fir1習題 6 — MATLAB:用 kaiserord / fir1 做 Kaiser 設計演習 6 — MATLAB:kaiserord / fir1 によるカイザー窓設計Problem: Implement the benchmark spec of §14.6.2 in MATLAB: $\omega_p = 0.22\pi$, $\omega_s = 0.29\pi$, passband ripple $\le 1$ dB, stopband attenuation $\ge 40$ dB. Use kaiserord + fir1 to design the filter, plot the magnitude response in dB against the spec mask, and compare the resulting number of taps with a Parks–McClellan design from firpmord/firpm.問題:在 MATLAB 裡實作 §14.6.2 的基準規格:$\omega_p = 0.22\pi$、$\omega_s = 0.29\pi$、通帶漣波 $\le 1$ dB、阻帶衰減 $\ge 40$ dB。用 kaiserord 加 fir1 設計這個濾波器,把 dB 大小響應對著規格遮罩畫出來,再把得到的抽頭數與 firpmord/firpm 的 Parks–McClellan 設計做比較。問題:§14.6.2 のベンチマーク仕様を MATLAB で実装せよ:$\omega_p = 0.22\pi$、$\omega_s = 0.29\pi$、通過帯域リップル $\le 1$ dB、阻止帯域減衰量 $\ge 40$ dB。kaiserord と fir1 でフィルタを設計し、dB 表示の振幅応答を仕様マスクと重ねて描き、得られたタップ数を firpmord/firpm による Parks–McClellan 設計と比較せよ。
Convert the dB spec into linear ripples first ($1$ dB passband ⇒ $\delta_p = (10^{1/20}-1)/(10^{1/20}+1) \approx 0.0575$; $-40$ dB ⇒ $\delta_s = 0.01$). Frequencies for fir1/kaiserord are normalized to the Nyquist frequency (1 corresponds to $\pi$):先把 dB 規格換算成線性漣波(通帶 $1$ dB ⇒ $\delta_p = (10^{1/20}-1)/(10^{1/20}+1) \approx 0.0575$;$-40$ dB ⇒ $\delta_s = 0.01$)。給 fir1/kaiserord 的頻率,是對奈奎斯特頻率正規化過的(1 對應 $\pi$):まず dB 仕様を線形のリップルへ換算する(通過帯域 $1$ dB ⇒ $\delta_p = (10^{1/20}-1)/(10^{1/20}+1) \approx 0.0575$、$-40$ dB ⇒ $\delta_s = 0.01$)。fir1/kaiserord に渡す周波数はナイキスト周波数で正規化されている(1 が $\pi$ に対応する):
% spec: wp = 0.22*pi, ws = 0.29*pi, Rp = 1 dB, As = 40 dB
dp = (10^(1/20)-1)/(10^(1/20)+1); % 1 dB passband -> delta_p = 0.0575
ds = 10^(-40/20); % 40 dB stopband -> delta_s = 0.01
% --- Kaiser window design ---
[n, Wn, beta, ftype] = kaiserord([0.22 0.29], [1 0], [dp ds]);
hK = fir1(n, Wn, ftype, kaiser(n+1, beta), 'noscale');
fprintf('Kaiser: %d taps, beta = %.3f\n', n+1, beta);
% --- Parks-McClellan for comparison ---
[n2, fo, ao, w] = firpmord([0.22 0.29], [1 0], [dp ds]);
hPM = firpm(n2, fo, ao, w);
fprintf('Parks-McClellan: %d taps\n', n2+1);
% --- plot against the spec mask ---
[H, wfr] = freqz(hK, 1, 4096);
plot(wfr/pi, 20*log10(abs(H))); hold on; grid on;
plot([0.29 1], [-40 -40], 'k--', [0 0.22], [-1 -1], 'k--');
xlabel('\omega/\pi'); ylabel('|H| (dB)');
title('Kaiser windowed FIR vs. spec');
Result: kaiserord returns $\beta \approx 3.40$ (matching Exercise 4) and ≈ 64–65 taps; firpmord/firpm meets the same spec with ≈ 45 taps (order 44, Table 7.3) — the equiripple design saves roughly 20 taps. The regenerated result (Python/scipy, signal.kaiserord(40, 0.07) ⇒ 65 taps, $\beta = 3.395$, signal.firwin cutoff $0.255\pi$):結果:kaiserord 回傳 $\beta \approx 3.40$(與習題 4 相符)以及約 64–65 個抽頭;firpmord/firpm 用約 45 個抽頭(階數 44,表 7.3)就滿足同一份規格——等漣波設計省下大約 20 個抽頭。重新產生的結果(Python/scipy,signal.kaiserord(40, 0.07) ⇒ 65 個抽頭、$\beta = 3.395$、signal.firwin 截止頻率 $0.255\pi$):結果:kaiserord は $\beta \approx 3.40$(演習 4 と一致)と約 64–65 タップを返す。firpmord/firpm は同じ仕様を約 45 タップ(次数 44、表 7.3)で満たす —— 等リップル設計はおよそ 20 タップを節約する。再生成した結果(Python/scipy、signal.kaiserord(40, 0.07) ⇒ 65 タップ、$\beta = 3.395$、signal.firwin の遮断周波数 $0.255\pi$):