Moving average filter延伸文章資訊,搜尋引擎最佳文章推薦

1. 3.2.1 FIR Filter

Moving Average Filter 是藉由對濾波範圍內訊號取平均值,目的為降低離散時間訊號中的雜訊,增加峰值的可辨度。

其特點為理論簡單,計算快速。

說明. 令 代表長度為N 之輸入 ...3.2Filter本模組提供數種常見之濾波器,以濾除訊號中特定的資料內容。

FIRFilter:基本的有限脈衝響應濾波器(FiniteImpulseResponseFilter)。

MedianFilter:對抑制脈衝雜訊效果顯著的中位數濾波器。

MovingAverageFilter:移動平均濾波器可消除隨機產生之雜訊。

IterativeGaussianFilter:此元件目的在於濾除訊號非週期之部份。

TrendEstimater:為IterativeGaussianFilter之簡化版,可抓取非週期訊號。

NotchFilter:此元件目的在於濾除訊號中的某個頻率。

CombFilter:為一梳形濾波器,用於濾除一系列等間距的頻率。

3.2.1FIRFilter有限脈衝響應(FiniteImpulseResponse)濾波器,是訊號處理中基本(Basis)濾波器原型,可針對高頻、低頻或指定的頻段濾波。

有限(Finite)是指此濾波器對於訊號的反應時間是有限的。

說明假設有一訊號,為如下圖形:傅立葉轉換後圖型如下,在此希望將其高頻部份濾除,只保留低頻部份:(黑細線為原本訊號的傅立葉轉換,紅粗線為希望保留與濾除的頻率分界)因此,在傅立葉空間定義出上述紅線的函數,並將此函數與原本訊號的傅立葉轉換相乘:再做傅立葉逆轉換,就可得到濾除高頻部份的圖型:以上是為低通濾波器,若為高通則為:帶通(BandPass):反帶通(BandStop)ByPass則為全通。

參數設定(Properties)本模組接受實數(realnumber),單通道(singlechannel)或多通道(multi-channel),regular的訊號(signal)或聲音訊號(audio)輸入;輸出訊號格式與輸入訊號相同。

FIRFilter的主要參數為FilterType,預設包括LowPass、HighPass、BandPass、BandStop、ByPass等五種型態。

LowPass表示過濾掉頻率F1以上的訊號,HighPass則過濾頻率F1以下的訊號。

BandPass代表保留頻段F1至F2間的訊號,BandStop則是濾掉頻段F1至F2間的訊號。

ByPass則為所有頻率皆可通(即為原輸入訊號)。

各參數定義與預設值如下表:參數名稱參數定義預設值FilterType預設五種形態,包括LowPass、HighPass、BandPass、BandStop、ByPass。

LowPassF1對於LowPass以及HighPass而言,F1代表濾波器過濾頻段的分界點;對於BandPass、BandStop,F1代表濾波器過濾頻段的起始點,單位為Hz。

10NormalizedF1顯示以輸入訊號之Samplingfrequency為依據,正規化後的F1值。

應輸入訊號不同而異。

F2對於FilterType選擇BandPass與BandStop者,會出現濾波器過濾頻段不終點F2,單位為Hz。

50FilterOrder濾波器轉換函數的離散點,N即為N-orderFilter。

範例(Example)本範例將示範以三個頻率各為10、51、193Hz的SineWave加上振幅0.1的WhiteNoise當作輸入訊號,再用FIRFilter過濾不同頻率的訊號,步驟如下:Network視窗下選擇Source/Noise產生一個白色雜訊,設定Properties/Amplitude為0.3,再用Source/SineWave產生三個SineWave,並改變其Properties/SignalFreq為10、51、193Hz,最後以Compute/Channel/Mixer將上述訊號混合(將各訊號源之Output拉至Mixer的Input),用Viewer/ChannelViewer繪出。

可以將Mixer的結果接上Compute/Transform/FourierTransform,以觀察頻譜圖,以方便接下來的FIRFilter設計於 Mixer圖示選擇Compute/Filter/FIRFilter,調整Properti



2. Frequency Response of the Moving Average Filter

Frequency Response of the Running Average Filter ... The frequency response of an LTI system is the DTFT of the impulse response,. H(ω) = ∑(m = − ∞ to ∞) h(m) ...SkiptomaincontentUCBerkeleyEECSDept.HomePiazzzabSpaceLogisticsOverviewTextbookScheduleTopic notesSidebartopicsExamsResourcesHomeworkReadingLabsEECS20N:SignalsandSystemsHome Up to Topics Previous NextWeek12Freq.ResponseContinuoustimeMoving AverageSignal SpacesTransformsSymmetryInverseExamplesLinearityUsing LinearityConstantsExponentialsSinusoidDiscreteFourier TransformsConvolutionSignalproductsFrequencyResponseoftheRunningAverageFilter ThefrequencyresponseofanLTIsystemistheDTFToftheimpulseresponse,H(ω)=∑(m=−∞to∞)h(m)e−jωm.TheimpulseresponseofanL-samplemovingaverageish(n)=1/L,forn=0,1,...,L−1h(n)=0,otherwiseSincethemovingaveragefilterisFIR,thefrequencyresponsereducestothefinitesumH(ω)=(1/L)∑(m=0toL−1)e−jωm..WecanusetheveryusefulidentitytowritethefrequencyresponseasH(ω)=(1/L)(1−e−jωL)/(1−e−jω).wherewehaveleta=e−jω,N=0,andM=L−1.Wemaybeinterestedinthemagnitudeofthisfunctioninordertodeterminewhichfrequenciesgetthroughthefilterunattenuatedandwhichareattenuated.BelowisaplotofthemagnitudeofthisfunctionforL=4(red),8(green),and16(blue).Thehorizontalaxisrangesfromzerotoπradianspersample.Noticethatinallthreecases,thefrequencyresponsehasalowpasscharacteristic.Aconstantcomponent(zerofrequency)intheinputpassesthroughthefilterunattenuated.Certainhigherfrequencies,suchasπ/2,arecompletelyeliminatedbythefilter.However,iftheintentwastodesignalowpassfilter,thenwehavenotdoneverywell.Someofthehigherfrequenciesareattenuatedonlybyafactorofabout1/10(forthe16pointmovingaverage)or1/3(forthefourpointmovingaverage).Wecandomuchbetterthanthat.TheaboveplotwascreatedbythefollowingMatlabcode:omega=0:pi/400:pi;H4=(1/4)*(1-exp(-i*omega*4))./(1-exp(-i*omega));H8=(1/8)*(1-exp(-i*omega*8))./(1-exp(-i*omega));H16=(1/16)*(1-exp(-i*omega*16))./(1-exp(-i*omega));plot(omega,[abs(H4);abs(H8);abs(H16)])axis([0,pi,0,1]) Copyright©2000--UniversityofCalifor



3. Understand Moving Average Filter with Python & Matlab

Understand Moving Average Filter with Python & Matlab · 1) It takes. L input points, computes the average of those. L · 2) Due to the computation ...SkiptocontentThemovingaveragefilterisasimpleLowPassFIR(FiniteImpulseResponse)filtercommonlyusedforsmoothinganarrayofsampleddata/signal.Ittakessamplesofinputatatimeandtakestheaverageofthose-samplesandproducesasingleoutputpoint.ItisaverysimpleLPF(LowPassFilter)structurethatcomeshandyforscientistsandengineerstofilterunwantednoisycomponentfromtheintendeddata.Asthefilterlengthincreases(theparameter)thesmoothnessoftheoutputincreases,whereasthesharptransitionsinthedataaremadeincreasinglyblunt.Thisimpliesthatthisfilterhasexcellenttimedomainresponsebutapoorfrequencyresponse.TheMAfilterperformsthreeimportantfunctions:1)Ittakesinputpoints,computestheaverageofthose-pointsandproducesasingleoutputpoint2)Duetothecomputation/calculationsinvolved,thefilterintroducesadefiniteamountofdelay3)ThefilteractsasaLowPassFilter(withpoorfrequencydomainresponseandagoodtimedomainresponse).ImplementationThedifferenceequationfora-pointdiscrete-timemovingaveragefilterwithinputrepresentedbythevectorandtheaveragedoutputvector,is Forexample,a-pointMovingAverageFIRfiltertakesthecurrentandpreviousfoursamplesofinputandcalculatestheaverage.ThisoperationisrepresentedasshownintheFigure1withthefollowingdifferenceequationfortheinputoutputrelationshipindiscrete-time.Figure1:Discrete-time5-pointMovingAverageFIRfilterTheunitdelayshowninFigure1isrealizedbyeitherofthetwooptions:RepresentingtheinputsamplesasanarrayinthecomputermemoryandprocessingthemUsingD-Flipflopshiftregistersfordigitalhardwareimplementation.Ifeachdiscretevalueoftheinputisrepresentedasa-bitsignallinefromADC(analogtodigitalconverter),thenwewouldrequire4setsof12-Flipflopstoimplementthe-pointmovingaveragefiltershowninFigure1.Z-TransformandTransferfunctionInsignalprocessing,delayingasignalbysampleperiod(unitdelay)isequivalenttomultiplyingtheZ-transformby.Byapplyingthisidea,wecanfindtheZ-transformofthe-po



4. 淺談動平均濾波器(作者:黃俊傑)

動平均濾波器(moving average filter) 可說是世界上使用最廣泛的一種濾波器了; 在股市裡面,每天都可以看到動平均濾波器的應用,股價趨勢圖裡面的週線、月線與年線, ...程式人雜誌--2013年12月號(開放公益出版品)淺談動平均濾波器(作者:黃俊傑)淺談動平均濾波器(作者:黃俊傑)簡介動平均濾波器(movingaveragefilter)可說是世界上使用最廣泛的一種濾波器了;在股市裡面,每天都可以看到動平均濾波器的應用,股價趨勢圖裡面的週線、月線與年線,都是長度不等的動平均輸出圖形。

我們在實作訊號處理的時候,也很常應用這個簡單又有效率的動平均濾波器。

由於它應用廣泛,許多程式設計師也許沒有修過數位訊號處理的課程,不熟悉數位訊號處理分析方式,但是又需要寫這樣的程式。

因此,在這一篇文章中,筆者將會儘量以實例來介紹動平均濾波器的概念,幾種不同的實作方式以及優缺點。

最直觀的動平均濾波器,當屬於simplemovingaverage(SMA)了,也是應用在股市以及很多統計上面的動平均。

SMA的定義就是取目前輸入之前的N個取樣的非權重平均。

用數學式表示的話,就是或是在訊號處理上我們慣用以下的時域表示式其中,y(n)代表目前輸出值,而x(n)代表目前輸入值。

這個濾波器應用在股市裡,就是我們在股票市場裡常常看到的曲線圖,如週線、月線與年線,分別是N=7,N=30,N=365的每日收盤價格的動平均輸出圖形。

使用濾波器來形塑(shape)你的資料的目的,通常都是為了要讓資料的重點能夠呈現出來,比方說,股市的波動常常有一個快速變動的部份,與慢速變動的部份,而所謂的慢速變動的部份,我們認為那是長期的趨勢,是我們想要觀察的重點,所以將濾波器應用在每日收盤價格上,將「快速變動的部份濾掉」,保留慢速變動的部份,就成了週線、月線與年線了。

以數位訊號處理理論來說,那些慢速變動就是指低頻的部份,快速變動的部份就是高頻的部份,因此以數位訊號處理的術語來說,動平均濾波器就是一個低通濾波器(lowpassfilter),意思就是低頻能夠通過的濾波器,而高頻的部份就被過濾掉了。

又比方心跳表顯示每分鐘心跳率是用一個數值,而我們知道心跳每幾秒鐘記錄一次的話,一分鐘裡面會有上上下下的變化,不是一直維持在某一個數值,每分鐘心跳率就是一分鐘裡面心跳的平均數值,以方便我們在心跳表上顯示出來,但是以每分鐘的平均數值顯示出來的時候,如果你沒有很大的運動變化,每分鐘心跳率是維持在一個定值的。

常用動平均濾波器在本節中,我們會介紹四種常見的動平均濾波器,前兩種動平均濾波器直接實作了上一節所描述的SMA動平均濾波器,這兩種只有小部分的差異。

而第三種是SMA的變形,引進了回授的概念來簡化實作的複雜度,因此前三種廣義上都是SMA動平均濾波器的實作。

第四種我們要介紹的是指數平均濾波器,與前三種不太一樣,但是有著實作簡單的好處。

在定點訊號處理裡,我們有兩種直接實作SMA的方法,第一種就如上一節中方程式2描述的式子,先做加總,再除以N來得到結果。

我們以N=4為例子說明這個濾波器,其方程式會是:假設我們觀察的是餐廳每半小時的顧客人數,如表1中的「輸入」欄位所示,「輸出」欄位所示的就是這個N=4的動平均濾波器的輸出序列,計算方式就是依照方程式3,以x(n)為目前輸入,y(n)為目前輸出值,以輸入為20那一欄為例,這時候表1:餐廳每半小時顧客人數以及其動平均值輸出0.000.000.000.002.507.5015.0023.7526.2523.7517.508.753.751.250.00圖1:N=4的動平均輸出入關係圖圖1則是把這個輸出入關係繪製成圖形表示,我們可以看出來,當輸入發生變化的時候,輸出值會以延遲而且比較平緩的趨勢呈現,延遲是因為動平均濾波器是計算前N個輸入,而比較平緩的趨勢就是動平均濾波器對這個輸入值重塑後的結果。

觀察方程式3可以發現,有兩個輸入數列特別有趣,分別是+1,-1,+1,-1,+1,-1,...這種正負交互出現而且絕對值是一樣的數列。

把這個數列輸入到上述的方程式,我們會得到全為零的輸出。

另一個有趣的數入數列是0,+1,0,-1,0,+1,0,-1,...也就是將上一個數列任兩個數值間都插入一個零值。

於是這個數列就變成任意相鄰四個數字加總起來為零,使得輸出值皆為零的數列。

觀察這個兩個數列,第一個數列週期為2,第二個數列週期為4。

而第一



5. How Is a Moving Average Filter Different from an FIR Filter?

The moving average filter is a special case of the regular FIR filter. Both filters have finite impulse responses. The moving average filter uses a sequence ...SkiptocontentDocumentationHelpCenterDocumentationSearchSupportSupportMathWorksSearchMathWorks.comMathWorksSupportCloseMobileSearchOpenMobileSearchOff-CanvasNavigationMenuToggleDocumentationHomeDSPSystemToolboxStatisticsandLinearAlgebraMeasurementsandStatisticsDSPSystemToolboxStatisticsandLinearAlgebraHowIsaMovingAverageFilterDifferentfromanFIRFilter?OnthispageFrequencyResponseofMovingAverageFilterandFIRFilterRelatedTopicsDocumentationAllExamplesFunctionsBlocksAppsVideosAnswersTrialSoftwareTrialSoftwareProductUpdatesProductUpdatesResourcesDocumentationAllExamplesFunctionsBlocksAppsVideosAnswersMainContentHowIsaMovingAverageFilterDifferentfromanFIRFilter?ThemovingaveragefilterisaspecialcaseoftheregularFIRfilter.Bothfiltershavefiniteimpulseresponses.Themovingaveragefilterusesasequenceofscaled1sascoefficients,whiletheFIRfiltercoefficientsaredesignedbasedonthefilterspecifications.Theyarenotusuallyasequenceof1s.Themovingaverageofstreamingdataiscomputedwithafiniteslidingwindow:movAvg=x[n]+x[n−1]+...+x[n−N]N+1N+1isthelengthofthefilter.ThisalgorithmisaspecialcaseoftheregularFIRfilterwiththecoefficientsvector,[b0,b1,...,bN].FIROutput=b0x[n]+b1x[n−1]+...+bNx[n−N]Tocomputetheoutput,theregularFIRfiltermultiplieseachdatasamplewithacoefficientfromthe[b0,b1,...,bN]vectorandaddstheresult.Themovingaveragefilterdoesnotuseanymultipliers.Thealgorithmaddsallthedatasamplesandmultipliestheresultwith1/filterLength.FrequencyResponseofMovingAverageFilterandFIRFilterOpenLiveScriptComparethefrequencyresponseofthemovingaveragefilterwiththatoftheregularFIRfilter.SetthecoefficientsoftheregularFIRfilterasasequenceofscaled1's.Thescalingfactoris1/|filterLength|.Createadsp.FIRFilterSystemobject™andsetitscoefficientsto1/40.Tocomputethemovingaverage,createadsp.MovingAverageSystemobjectwithaslidingwindowoflength40.Bothfiltershavethesamecoefficient



常見投資理財問答


延伸文章資訊