在有限長度數位濾波器的設計中,最小平均平方誤差(英文:least mean-square error)是所設計的濾波器響應與理想濾波器響應在欲探討的頻段中的最小誤差。由於所設計的數位濾波器的長度不是無限長,所以在設計上和完美的濾波器會存在誤差。是訊號工程師會關心設計的濾波器的響應重點。此平均誤差利用統計學的方均值來計算求得。 本條目存在以下問題,請協助改善本條目或在討論頁針對議題發表看法。 此條目可能需要清理,以符合維基百科品質標準。 (2023年6月15日) 此條目需要精通或熟悉數位訊號處理的編者參與及協助編輯。 (2023年6月15日) 定義 M S E ≜ 1 f s ∫ − f s / 2 f s / 2 | R ( f ) − H d ( f ) | 2 d f {\displaystyle MSE\triangleq {\frac {1}{f_{s}}}\int \limits _{-f_{s}/2}^{f_{s}/2}|R(f)-H_{d}(f)|^{2}df} 其中 R ( f ) {\displaystyle R(f)} 為設計濾波器響應,有k+1項: R ( F ) = ∑ n = 0 k s [ n ] c o s ( 2 π n F ) {\displaystyle R(F)=\sum _{n=0}^{k}s[n]cos(2\pi nF)} , F {\displaystyle F} 表示頻率變數對取樣頻率 f s {\displaystyle f_{s}} 的正歸化參數: F = f f s {\displaystyle F={\frac {f}{f_{s}}}} ,是離散化的頻率(normalized frequency)。此為離散時間傅立葉轉換表示法 其中 H d ( f ) = ∑ n h [ n ] e − j 2 π f f s = H d ( f ) = ∑ n h [ n ] e − j 2 π n F {\displaystyle H_{d}(f)=\sum _{n}h[n]e^{-j2\pi f \over f_{s}}=H_{d}(f)=\sum _{n}h[n]e^{-j2\pi nF}} 是理想濾波器的離散時間傅立葉轉換表示法。 注意此算式中對頻譜的積分上下界,採取正負取樣頻率的一半即可。[1]因為響應函式已經被取樣,會讓信號頻譜具有週期性,其週期就是取樣頻率為 f s {\displaystyle f_{s}} 。所以探討MSE時,積分範圍採取 − f s 2 {\displaystyle -{\frac {f_{s}}{2}}} 到 f s 2 {\displaystyle {\frac {f_{s}}{2}}} 即可,節省運算量。 另外,此種將函數平方再對變數積分取平均的算法,類似對變數取 L 2 {\displaystyle L_{2}} 範數。即是對向量做二維的純量化平均的處理,和另一個設計濾波器做法Mini-max相比,做最佳化較容易,因為這是實函數平方微分後再積分的線性運算 Remove ads有限脈衝響應濾波器的設計應用 運用定義,將 F {\displaystyle F} 取代 f {\displaystyle f} 做變數變換: F = f f s {\displaystyle F={\frac {f}{f_{s}}}} , d F = 1 f s d f {\displaystyle dF={\frac {1}{f_{s}}}df} M S E = ∫ − 1 / 2 1 / 2 | R ( F ) − H d ( F ) | 2 d F = ∫ − 1 / 2 1 / 2 | ∑ n = 1 k s [ n ] c o s ( 2 π n F ) − H d ( F ) | 2 d F {\displaystyle {\begin{aligned}MSE&=\int _{-1/2}^{1/2}|R(F)-H_{d}(F)|^{2}dF\\&=\int _{-1/2}^{1/2}|\sum _{n=1}^{k}s[n]cos(2\pi nF)-H_{d}(F)|^{2}dF\\\end{aligned}}} 因為絕對值內函數是以時刻變數構成的實函數,所以可將絕對值平方直接寫成兩個實函數部分相乘。 M S E = ∫ − 1 / 2 1 / 2 ( ∑ v = 0 k s [ v ] c o s ( 2 π v F ) − H d ( F ) ) ( ∑ τ = 0 k s [ τ ] c o s ( 2 π τ F ) − H d ( F ) ) d F {\displaystyle MSE=\int _{-1/2}^{1/2}\left(\sum _{v=0}^{k}s[v]cos(2\pi vF)-H_{d}(F)\right)\left(\sum _{\tau =0}^{k}s[\tau ]cos(2\pi \tau F)-H_{d}(F)\right)dF} 將MSN對s{n]做偏微分, ∂ M S E ∂ s [ n ] = ∫ − 1 / 2 1 / 2 c o s ( 2 π n F ) ( ∑ τ = 0 k s [ τ ] c o s ( 2 π τ F ) − H d ( F ) ) d F + ∫ − 1 / 2 1 / 2 ( ∑ v = 0 k s [ v ] c o s ( 2 π v F ) − H d ( F ) ) d F {\displaystyle {\begin{aligned}{\frac {\partial MSE}{\partial s[n]}}&=\int _{-1/2}^{1/2}cos(2\pi nF){\Bigl (}\sum _{\tau =0}^{k}s[\tau ]cos(2\pi \tau F)-H_{d}(F){\Bigr )}dF\\&+\int _{-1/2}^{1/2}{\Bigl (}\sum _{v=0}^{k}s[v]cos(2\pi vF)-H_{d}(F){\Bigr )}dF\\\end{aligned}}} 將上式第一個等號後面的兩個 Σ {\displaystyle \Sigma } 項合併,因為引數起始值和最末項值相同。 ∂ M S E ∂ s [ n ] = 2 ∑ τ = 0 k s [ τ ] ∫ − 1 / 2 1 / 2 c o s ( 2 π τ F ) c o s ( 2 π n F ) d F − 2 ∫ − 1 / 2 1 / 2 H d ( F ) c o s ( 2 π n F ) d F , ∀ n = 0 , 1 , 2 , . . . k {\displaystyle {\begin{aligned}{\frac {\partial MSE}{\partial s[n]}}&=2\sum _{\tau =0}^{k}s[\tau ]\int _{-1/2}^{1/2}cos(2\pi \tau F)cos(2\pi nF)dF\\&-2\int _{-1/2}^{1/2}H_{d}(F)cos(2\pi nF)dF,\forall n=0,1,2,...k\\\end{aligned}}} 上式等號右邊的兩項中,都各有將餘弦函數從-1/2積分到1/2,又因為有兩個自變數係數不同的餘弦函數相乘,整個計算結果要分開討論。 Remove ads R ( F ) {\displaystyle R(F)} 與 H d ( F ) {\displaystyle H_{d}(F)} 項次 R ( F ) {\displaystyle R(F)} 與 H d ( F ) {\displaystyle H_{d}(F)} 的項次 n {\displaystyle n} 與 τ {\displaystyle \tau } 相異或相同,因為函數的正交性,會有不同的積分效果。此可由三角函數的積化合差驗證出來。 ∫ − 1 / 2 1 / 2 c o s ( 2 π τ F ) c o s ( 2 π n F ) d F = { 0 , n ≠ τ 1 / 2 , n = τ , n ≠ 0 1 , n = τ , n = 0 {\displaystyle \int _{-1/2}^{1/2}cos(2\pi \tau F)cos(2\pi nF)dF={\begin{cases}0,&n\neq \tau \\1/2,&n=\tau ,n\neq 0\\1,&n=\tau ,n=0\end{cases}}} 故可得: ∂ M S E ∂ s [ 0 ] = 2 s [ 0 ] × 1 − 2 ∫ − 1 / 2 1 / 2 H d ( F ) × 1 d F = 0 , ∀ n = 0 ∂ M S E ∂ s [ n ] = s [ n ] − 2 ∫ − 1 / 2 1 / 2 c o s ( 2 π n F ) H d ( F ) d F = 0 , ∀ n ≠ 0 {\displaystyle {\begin{aligned}{\frac {\partial MSE}{\partial s[0]}}&=2s[0]\times 1-2\int _{-1/2}^{1/2}H_{d}(F)\times 1dF=0,\forall n=0\\{\frac {\partial MSE}{\partial s[n]}}&=s[n]-2\int _{-1/2}^{1/2}cos(2\pi nF)H_{d}(F)dF=0,\forall n\neq 0\\\end{aligned}}} MSE 是設計上濾波器響應函數和理想函數之間的誤差,吾人會希望這個誤差越小越好,即是設計的響應要和理想的響應,在所有時刻n上的趨勢一樣。 故使: ∂ M S E ∂ s [ n ] = 0 {\displaystyle {\partial MSE \over \partial s[n]}=0} for all n. 可得: s [ 0 ] = ∫ − 1 / 2 1 / 2 H d ( F ) d F s [ n ] = 2 ∫ − 1 / 2 1 / 2 c o s ( 2 π n F ) H d ( F ) d F {\displaystyle {\begin{aligned}s[0]=\int _{-1/2}^{1/2}H_{d}(F)dF\\s[n]=2\int _{-1/2}^{1/2}cos(2\pi nF)H_{d}(F)dF\\\end{aligned}}} 觀察上式,若我們要得到濾波器的最小方均誤差,則要將理想濾波器頻域響應對餘弦函數做多項式內積。 最後將 s [ n ] {\displaystyle s[n]} 的值帶入 h [ k ] {\displaystyle h[k]} : { h [ k ] = s [ 0 ] h [ k + n ] = s [ n ] / 2 , h [ k − n ] = s [ n ] / 2 , for n = 1 , 2 , 3 , . . . , k h [ n ] = 0 , for n < 0 and n ≥ N . {\displaystyle {\begin{cases}h[k]=s[0]\\h[k+n]=s[n]/2,h[k-n]=s[n]/2,&{\text{for }}n=1,2,3,...,k\\h[n]=0,{\text{ for }}n<0{\text{ and }}n\geq N.\end{cases}}} h [ n ] {\displaystyle h[n]} 即為欲設計的濾波器脈衝響應式。 Remove ads結合權重函數 在數位濾波器設計中,可以利用權重函數 W ( F ) {\displaystyle W(F)} 去設計定頻段更接近理想值。則MSE則表示為: M S E = ∫ − 1 / 2 1 / 2 W ( F ) | R ( F ) − H d ( F ) | 2 d F = ∫ − 1 / 2 1 / 2 W ( F ) ( ∑ − 1 / 2 1 / 2 s [ τ ] ) c o s ( 2 π τ F ) − H d ( F ) ) d F {\displaystyle MSE=\int _{-1/2}^{1/2}W(F)|R(F)-H_{d}(F)|^{2}dF=\int _{-1/2}^{1/2}W(F){\Bigl (}\sum _{-1/2}^{1/2}s[\tau ])cos(2\pi \tau F)-H_{d}(F){\Bigr )}dF} MSE對s[n]的微分值為零可改寫為: ∂ M S E ∂ s [ n ] = 2 ∫ − 1 / 2 1 / 2 W ( F ) c o s ( 2 π n F ) ( ∑ t a u k s [ τ ] c o s ( 2 π τ F ) − H d ( F ) ) d F {\displaystyle {\frac {\partial MSE}{\partial s[n]}}=2\int _{-1/2}^{1/2}W(F)cos(2\pi nF){\biggl (}\sum _{tau}^{k}s[\tau ]cos(2\pi \tau F)-H_{d}(F){\biggr )}dF} = ∑ τ = 0 k s [ τ ] ∫ − 1 / 2 1 / 2 W ( F ) c o s ( 2 π n F ) c o s ( 2 π τ F ) d F − ∫ − 1 / 2 1 / 2 W ( F ) H d ( F ) c o s ( 2 π n F ) d f = 0 , n ∈ [ 0 , k ] {\displaystyle =\sum _{\tau =0}^{k}s[\tau ]\int _{-1/2}^{1/2}W(F)cos(2\pi nF)cos(2\pi \tau F)dF-\int _{-1/2}^{1/2}W(F)H_{d}(F)cos(2\pi nF)df=0,n\in [0,k]} ⇒ ∑ τ = 0 k s [ τ ] ∫ − 1 / 2 1 / 2 W ( F ) c o s ( 2 π n F ) c o s ( 2 π τ F ) d F = ∫ − 1 / 2 1 / 2 W ( F ) H d ( F ) c o s ( 2 π n F ) d F {\displaystyle \Rightarrow \sum _{\tau =0}^{k}s[\tau ]\int _{-1/2}^{1/2}W(F)cos(2\pi nF)cos(2\pi \tau F)dF=\int _{-1/2}^{1/2}W(F)H_{d}(F)cos(2\pi nF)dF} 可再將上式寫成矩陣式: [ A [ 0 , 0 ] A [ 0 , 1 ] A [ 0 , 2 ] . . . A [ 0 , k ] A [ 1 , 0 ] A [ 1 , 1 ] A [ 1 , 2 ] . . . A [ 1 , k ] ⋮ ⋮ ⋮ ⋱ ⋮ A [ k , 0 ] A [ k , 1 ] A [ k , 2 ] ⋯ A [ k , k ] ] [ s [ 0 ] s [ 1 ] ⋮ s [ k ] ] = [ B [ 0 ] B [ 1 ] ⋮ B [ k ] ] {\displaystyle {\begin{bmatrix}A[0,0]&A[0,1]&A[0,2]&...&A[0,k]\\A[1,0]&A[1,1]&A[1,2]&...&A[1,k]\\\vdots &\vdots &\vdots &\ddots &\vdots \\A[k,0]&A[k,1]&A[k,2]&\cdots &A[k,k]\end{bmatrix}}{\begin{bmatrix}s[0]\\s[1]\\\vdots \\s[k]\end{bmatrix}}={\begin{bmatrix}B[0]\\B[1]\\\vdots \\B[k]\end{bmatrix}}} A矩陣每一行表示不同 τ {\displaystyle \tau } 代表的數值,每一列代表不同n代表的數值;s向量與B向量每一列表示不同n代表的數值。 其中: A [ n , τ ] = ∫ − 1 / 2 1 / 2 W ( F ) c o s ( 2 π n F ) c o s ( 2 π τ F ) d F , B [ n ] = ∫ − 1 / 2 1 / 2 W ( F ) H d ( F ) c o s ( 2 π n F ) d F {\displaystyle A[n,\tau ]=\int _{-1/2}^{1/2}W(F)cos(2\pi nF)cos(2\pi \tau F)dF,B[n]=\int _{-1/2}^{1/2}W(F)H_{d}(F)cos(2\pi nF)dF} 經由此舉陣式可解出帶有權重函數設計的 s [ n ] {\displaystyle s[n]} 。 最後將 s [ n ] {\displaystyle s[n]} 帶入 h [ k ] {\displaystyle h[k]} : { h [ k ] = s [ 0 ] h [ k + n ] = s [ n ] / 2 , h [ k − n ] = s [ n ] / 2 , for n = 1 , 2 , 3 , . . . , k h [ n ] = 0 , for n < 0 and n ≥ N . {\displaystyle {\begin{cases}h[k]=s[0]\\h[k+n]=s[n]/2,h[k-n]=s[n]/2,&{\text{for }}n=1,2,3,...,k\\h[n]=0,{\text{ for }}n<0{\text{ and }}n\geq N.\end{cases}}} h [ k ] {\displaystyle h[k]} 即是欲設計的濾波器響應。 Remove ads參考文獻Loading content...Loading related searches...Wikiwand - on Seamless Wikipedia browsing. On steroids.Remove ads