w n = c k v n k (1.226) w n = c k v n k + d k w n k (1.227) Clearly non-recursive filters are a special case of recursive filters where M=0.

Similar documents
Time Series Analysis: 4. Linear filters. P. F. Góra

EE482: Digital Signal Processing Applications

Time Series Analysis: 4. Digital Linear Filters. P. F. Góra

David Weenink. First semester 2007

Chapter 7: Filter Design 7.1 Practical Filter Terminology

DIGITAL SIGNAL PROCESSING UNIT III INFINITE IMPULSE RESPONSE DIGITAL FILTERS. 3.6 Design of Digital Filter using Digital to Digital

The Hilbert Transform

ECE 410 DIGITAL SIGNAL PROCESSING D. Munson University of Illinois Chapter 12

Design of IIR filters

Lecture 3 - Design of Digital Filters

-Digital Signal Processing- FIR Filter Design. Lecture May-16

Digital Signal Processing

INFINITE-IMPULSE RESPONSE DIGITAL FILTERS Classical analog filters and their conversion to digital filters 4. THE BUTTERWORTH ANALOG FILTER

Responses of Digital Filters Chapter Intended Learning Outcomes:

Filter Analysis and Design

SIGNALS AND SYSTEMS LABORATORY 4: Polynomials, Laplace Transforms and Analog Filters in MATLAB

Like bilateral Laplace transforms, ROC must be used to determine a unique inverse z-transform.

Digital Control & Digital Filters. Lectures 21 & 22

PS403 - Digital Signal processing

UNIT - III PART A. 2. Mention any two techniques for digitizing the transfer function of an analog filter?

DISCRETE-TIME SIGNAL PROCESSING

Digital Signal Processing Lecture 8 - Filter Design - IIR

E : Lecture 1 Introduction

The Approximation Problem

CMPT 889: Lecture 5 Filters

1 1.27z z 2. 1 z H 2

Digital Filters. Linearity and Time Invariance. Linear Time-Invariant (LTI) Filters: CMPT 889: Lecture 5 Filters

Question Paper Code : AEC11T02

Digital Signal Processing

DIGITAL SIGNAL PROCESSING. Chapter 6 IIR Filter Design

LAB 6: FIR Filter Design Summer 2011

Lecture 27 Frequency Response 2

LINEAR-PHASE FIR FILTERS DESIGN

Fourier Methods in Digital Signal Processing Final Exam ME 579, Spring 2015 NAME

Lecture 6: Discrete Fourier Transform

Digital Filters Ying Sun

ELEG 305: Digital Signal Processing

Lecture 16: Filter Design: Impulse Invariance and Bilinear Transform

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EC2314- DIGITAL SIGNAL PROCESSING UNIT I INTRODUCTION PART A

Tutorial Sheet #2 discrete vs. continuous functions, periodicity, sampling

Introduction to Signal Analysis Parts I and II

Lecture 19 IIR Filters

Design IIR Butterworth Filters Using 12 Lines of Code

Representing a Signal

Cast of Characters. Some Symbols, Functions, and Variables Used in the Book

FILTER DESIGN FOR SIGNAL PROCESSING USING MATLAB AND MATHEMATICAL

Detailed Solutions to Exercises

Discrete Time Systems

SPEECH ANALYSIS AND SYNTHESIS

(Refer Slide Time: 01:28 03:51 min)

Filter structures ELEC-E5410

DSP Configurations. responded with: thus the system function for this filter would be

UNIVERSITY OF OSLO. Please make sure that your copy of the problem set is complete before you attempt to answer anything.

Lecture 17: variance in a band = log(s xx (f)) df (2) If we want to plot something that is more directly representative of variance, we can try this:

Chapter 7: IIR Filter Design Techniques

Speaker: Arthur Williams Chief Scientist Telebyte Inc. Thursday November 20 th 2008 INTRODUCTION TO ACTIVE AND PASSIVE ANALOG

EE -213 BASIC CIRCUIT ANALYSIS LAB MANUAL

UNIVERSITY OF OSLO. Faculty of mathematics and natural sciences. Forslag til fasit, versjon-01: Problem 1 Signals and systems.

Time series analysis in neuroscience. Lecture 6. FIR and IIR filters

Recursive Gaussian filters

Introduction to Digital Signal Processing

Problem Set 9 Solutions

CHAPTER 2 RANDOM PROCESSES IN DISCRETE TIME

butter butter Purpose Syntax Description Digital Domain Analog Domain

Multimedia Signals and Systems - Audio and Video. Signal, Image, Video Processing Review-Introduction, MP3 and MPEG2

Transform analysis of LTI systems Oppenheim and Schafer, Second edition pp For LTI systems we can write

EE -213 BASIC CIRCUIT ANALYSIS LAB MANUAL

EE 521: Instrumentation and Measurements

Digital Signal Processing

APPLIED SIGNAL PROCESSING

Let H(z) = P(z)/Q(z) be the system function of a rational form. Let us represent both P(z) and Q(z) as polynomials of z (not z -1 )

Electronic Circuits EE359A

Introduction to Biomedical Engineering

Linear Algebra in Numerical Methods. Lecture on linear algebra MATLAB/Octave works well with linear algebra

Lecture 7 Discrete Systems

Digital Signal Processing IIR Filter Design via Bilinear Transform

Chapter 3 Data Acquisition and Manipulation

1. FIR Filter Design

IT DIGITAL SIGNAL PROCESSING (2013 regulation) UNIT-1 SIGNALS AND SYSTEMS PART-A

Fourier Series Representation of

EA2.3 - Electronics 2 1

Review of Discrete-Time System

On the Frequency-Domain Properties of Savitzky-Golay Filters

Lecture 9 Infinite Impulse Response Filters

ESS Finite Impulse Response Filters and the Z-transform

2.1 Basic Concepts Basic operations on signals Classication of signals

Filter Banks II. Prof. Dr.-Ing. G. Schuller. Fraunhofer IDMT & Ilmenau University of Technology Ilmenau, Germany

EE482: Digital Signal Processing Applications

Discrete-time first-order systems

Filters and Tuned Amplifiers

2.161 Signal Processing: Continuous and Discrete Fall 2008

A=randn(500,100); mu=mean(a); sigma_a=std(a); std_a=sigma_a/sqrt(500); [std(mu) mean(std_a)] % compare standard deviation of means % vs standard error

Ch. 7: Z-transform Reading

Introduction to DSP Time Domain Representation of Signals and Systems

ELEG 5173L Digital Signal Processing Ch. 5 Digital Filters

The Approximation Problem

Sensors. Chapter Signal Conditioning

ω (rad/s)

ECG782: Multidimensional Digital Signal Processing

Department of Electrical and Computer Engineering Digital Speech Processing Homework No. 6 Solutions

Transcription:

Random Data 79 1.13 Digital Filters There are two fundamental types of digital filters Non-recursive N w n = c k v n k (1.226) k= N and recursive N M w n = c k v n k + d k w n k (1.227) k= N k=1 Clearly non-recursive filters are a special case of recursive filters where M=0. Non-recursive filters rely only on the values of the inputs, v, whichmayincludefuture values, particularly in the case where we are post-processing the data and hence have access to all values in the record. Recursive filters depend on the input values and previous values of the outputs as well, hence the name recursive. Examples Non-recursive

80 This filter is known as a smoothing by 5s filter. w n = 1 5 (v n 2 + v n 1 + v n + v n+1 + v n+2 ) (1.228) Recursive w n = w n 1 + 1 2 (v n + v n 1 ) (1.229) This is trapezoidal integration a good example of the breadth of digital filters which, although they have their roots in analog filters, are a much more general processing tool than simply modifying amplitude as a function of frequency in the tradition of lowpass, band-pass, and high-pass analog filters. Another example of a recursive filter is an exponential smoothing w n+1 = av n+1 +(1 a)w n 1 (0 <a<1) (1.230) 1.13.1 A Filter by Another Name Depending on the field, recursive and non-recursive filters go byoneofmanynames:

Random Data 81 Non-recursive Finite impulse response (FIR) filter Transversal filter Moving average (MA) filter Recursive Infinite impulse response (IIR) filter Ladder or lattice filter Auto-regressive moving average (ARMA) filter Auto-regressive integrated moving average (ARIMA) filter 1.13.2 Least Square Fitting of Polynomials The example non-recursive filter introduced above is probably familiar (or a variant of it). What exactly is this filter doing? Let s say we desire to smooth a signal by fitting adegreep polynomial to some M-point subset of the signal (which contains N points) and then replacing the central point of those being fitted with themeanvalueofthefit polynomial. Clearly we require N>M. For example, consider the simplest case, the fitting of a constant value through five points. Let t n be our time variable and then our polynomial is simply w n = A (1.231) Now, restricting ourselves to the case n = 2, 1, 0, 1, 2, we wish to minimize, in the least squares sense, f(a) where 2 f(a) = [v n A] 2 (1.232) n= 2

82 thus we differentiate with respect to A and set the result equal to 0. f(a) A = 2 n= 2 (v n A) =0 5A = 2 n= 2 v n (1.233) But recall that we simply want to replace v 0, our center value, by the mean of our polynomial, which is (1/5) 2 n= 2 v n = A. Hencewearedone,wereplacev 0 with w 0 = A or, generalizing, A = 1 5 Thus the impulse response of the filter is 2 n= 2 v n = w n (1.234) h = 1 [1 1 1 1 1] (1.235) 5 A logical question to ask is what is the frequency response function (transfer function) of this filter? Embedding an M point filter into a signal of length N =256andtaking the Fourier transform yields the following: H(f) 1 0.8 0.6 0.4 M=3 M=5 M=7 M=9 0.2 0 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 f/f s Clearly as M gets larger more spectral components are attenuated, and in particular, progressively lower frequencies are attenuated. Notice the ripples in the high frequency regions - clearly this is not a perfect low-pass filter.

Random Data 83 1.13.3 Filter Design - Spectral Approach Consider the following model filters Low-Pass High-Pass Notch Filter (Band Stop) Band Pass

84 It is often easiest to consider the desired filter in the frequency domain and then look at its impulse response function in the time domain. For example, the ideal filter is the rectangle function (or top-hat filter) in the spectral domain butweknowthatthisleads to the sinc function, and hence wiggles, in the temporal domain. Often this is acceptable and we can simply zero-out unwanted frequencies in the spectral domain keeping in mind that we will see ringing in the time domain. If this ringing is aconcernwecansmooth out the harsh edge, either by informally tweaking the coefficients or more formally by applying a smoothing function (say a smooth by 5s) to the rectangle filter. For example, consider the N =256pointrectanglefilterdefinedsuchthatthefirst16pointsare1and the next 112 points are zero (symmetry defines the rest). The inverse Fourier transform of this filter yields the impulse response function, h(t). Now take the same filter function and smooth it with a 7s filter (e.g., [ 1 1 1 1 1 1 1]/7). The results areshownbelow H(f) 1 0.8 0.6 0.4 0.2 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 f/f s

Random Data 85 1 0.8 0.6 h(t) 0.4 0.2 0 0.2 0.4 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 t/t The simple smoothing, which amounts to a linear transition over 7 points, strongly damps the oscillations in the impulse response function with only a modest effect on the attenuation of the spectral components around the filter s edge. 1.13.4 Filter Design - Temporal Approach We can write a general expression for digital filters of causal signals(signals that are zero for all negative times which is typically our case) in the time domainas w n = N M c k v n k + d j w n j (1.236) k=0 j=1 where M = 0 Non-recursive filter (FIR) M 0 Recursive filter (IIR) It can be shown that the transfer function corresponding to Eq 1.236 is H(f) = 1 N c k e i2πkfn t k=0 (1.237) M d j e i2πjfn t j=1

86 where t = T/(N 1) = 1/f s,thetimeincrement. Thusthetransferfunctioncan be represented as a rational fraction of two polynomials. In filter theory the roots of the numerator polynomial are known as the zeros of the filter and the roots of the denominator polynomial are known as the poles of the filter. 1.13.5 z-transform Looking at Eq 1.237 we see a lot of what look like Fourier coefficients. Defining and substituting into Eq 1.237 we have z = e i2πf t (1.238) H(z) = 1 N c k z k k=0 (1.239) M d j z j j=1 Now, if M =0Eq1.239reducestoapolynomialinz while if M 0wegetarational function in z. Inthelattercasethereistheissueofstability. Thisisbeyond the scope of our discussion but is covered in detail in any standard text ondigitalfilters. The z-transform behaves a lot like the Fourier transform. In particular the convolution in z space is N W (z) =H(z)V (z) w n = h n v n = h n k v k (1.240) k= N Thus H(z) isthetransferfunctionofthefilterandiscompletelydetermined by the ratio of two polynomials. Note, we can write (which is essentially the way Matlab defines the polynomial coefficients except the indices start at 1) H(z) = N b k z k k=0 (1.241) M a j z j j=0

Random Data 87 Our spectral approach via windowing in the frequency domain is a non-recursive approach. We can define a polynomial approximation to our window completely defining the transfer function. 1.13.6 Standard Recursive Filters (IIR) There are four fundamental types of Recursive filters 1. Butterworth 2. Chebychev I 3. Chebychev II 4. Elliptic Butterworth Filters The Butterworth filter is maximally flat in the pass band and stop band and is derived by minimizing the least square difference with respect to the ideal filter. The tradeoff is that there is no minimization of the transition band, therefore higher order (more costly) Butterworth filters are required to achieve steep transitions. The great advantage of the Butterworth filter is it is smooth - no ripples in either the stop or pass band.

88 Chebychev Type I Filters Chebychev Type I filters are maximally flat in the stop band (like the Butterworth filter) and minimize the absolute difference, relative to the ideal filter, in the pass band. This latter process is known as equiripple as the process of minimizing the absolute difference leads to ripples, potentially of near equal maximum amplitude. Chebychev Type II Filters Chebychev Type II filters are maximally flat in the pass band and equirippleinthestop band the opposite of the type I filter.

Random Data 89 Elliptical Filters Elliptical filters are equiripple in both the pass and stop band and minimize the transition width. The above three filters can be scene as special cases of Elliptic filters. 1.13.7 Phase Delay Amajorproblemwithdigitalfilterscanbephasedelay.E.g. 1 0.5 original signal forward forward and backward Amplitude 0 0.5 1 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 Frequency (Hz) Here I have applied a 1 st order Butterworth filter, in just the forward direction, and taking the output in the forward direction, flipping it (in Matlab this command is fliplr) and running the output a second time through the Butterworth filter (in Matlab this command is butter). As is apparent, the Butterworth filter introduces both phase delay and amplitude attenuation both of which are a function of frequency, as seen in the figure below:

90 Magnitude (db) Phase (degrees) 0 50 100 0 5 10 15 20 25 30 35 40 45 50 Frequency (Hz) 0 50 100 0 5 10 15 20 25 30 35 40 45 50 Frequency (Hz) In the above case I have used an original sample rate of 100 Hz, the sine wave is 1 Hz, and the filter is designed with a cutoff frequency at 2 Hz. There are design solutions to minimize phase delay with a single pass on the data, which might be necessary in real-time applications, but these generally sacrifice something to achieve smaller phase delay, generally the amplitude response. When the data to be filtered is already in hand there is an easy solution - run the data through the filter twice, once forward and once backward. Recall that in the frequency domain we have directional ambiguity hence the forward and backward frequencies look the same. Thus the possibly frequency dependent lag induced in the forward direction is completely undone in the backward direction. The resultant transfer function is given by H(f) effective = H 2 (1.242) The Matlab code for the above plot is: fs=100; t=0:1/fs:4.05; y=sin(2*pi*t); [b,a] = butter(1,2/fs); y f=filter(b,a,y); y ff=fliplr(filter(b,a,fliplr(y f)));

Random Data 91 plot(t,y, r,t,y f, b-.,t,y ff, g-- ) legend( original signal, forward, forward and backward ) xlabel( Time (s) ) ylabel( Amplitude ) 1.14 The Hilbert Transform The Hilbert transform is a transform from the time domain to the time domain. It is a powerful tool for us as it can be used to extract the instantaneous amplitude, phase, and frequency of a signal. For further discussions on the Hilbert transformseebracewellor Bendat and Piersol. The time domain definition of the Hilbert transform is x(t) =H[x(t)] = x(u) du (1.243) π(t u) where x(t) is the Hilbert transform of x(t) and H is our nomenclature for the Hilbert transform of. We recognize Eq 1.243 as a convolution integral. Thus we can write x(t) =x(t) 1 πt (1.244) We can begin to get an interpretation of the Hilbert transform by considering it in the spectral domain. X(f) =F[ x(t)] (1.245) Note that X(f) isthefouriertransformof x(t) andnotthehilberttransformofx(t) whichisdifferent.now,recallingthatinthespectraldomain the convolution is just a multiplication we need F [ ] 1 = i sgn f = πt i f > 0 0 f =0 i f < 0 (1.246)

92 where sgn is the signum function which returns the sign of its argument if the argument is non-zero and zero if the argument is zero. Therefore we have X(f) = i sgn fx(f) (1.247) Now, let s consider B(f) = i sgn f = e iπ/2 f>0 0 f =0 e iπ/2 f<0 (1.248) Thus we can write B(f) = B(f) e iφ b(f) (1.249) where B(f) =1 f 0andφ b is defined such that π/2 f>0 φ b = π/2 f<0 (1.250) which looks like Now, let X(f) = X(f) e iφx(f) (1.251) Therefore Thus X(f) = X(f) e i φ x(f) = X(f) e i[φx(f)+φ b(f)] (1.252) X(f) = X(f) (1.253) φ x (f)+π/2 f>0 φ x (f) (1.254) φ x (f) π/2 f<0

Random Data 93 Hence we see that for positive frequencies the Hilbert transform simply applies a frequency shift of 90 whereas for negative frequencies a frequency shift of -90 is applied. How do we extract the instantaneous information? From the analytic signal, defined as z(t) =x(t)+i x(t) (1.255) which we can write as z(t) =A(t)e iθ(t) (1.256) where A(t) is the instantaneous envelope signal of x(t) and θ(t) is the instantaneous phase angle of x(t), which are defined as A(t) = [ x 2 (t)+ x 2 (t) ] 1/2 = z(t) (1.257) [ ] x(t) θ(t) = tan 1 =2πft (1.258) x(t) respectively. Note that the instantaneous phase angle must be unwrapped, e.g., 2π must be added each time the signal wraps back around on itself. Now, we can find the instantaneous frequency from Eq 1.258 θ t =2πf f = 1 θ 2π t (1.259) where f is the instantaneous frequency. Example Consider a simple cosine wave, x =cos(2π 60 t) hencethefrequencyis60. Thesignal and its Hilbert transform (real z and imag z, respectively)looklike The amplitude function looks like

94 x(t) and H[x(t)] 1 0.5 0 0.5 x(t) H[x(t)] 1 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 t 1.05 1 0.95 A(t) 0.9 0.85 0.8 0.75 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 t and the unwrapped phase is 40 30 θ (radians) 20 10 0 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 t Differentiating the unwrapped phase yields the instantaneous frequency

Random Data 95 f 70 65 60 55 50 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 60.2 60.1 f 60 59.9 59.8 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 t Clearly there are transients at the beginning of the signals but these quickly fade away.

96 For reference the Matlab code to develop these signals is t = (0:1/1023:1); x = cos(2*pi*60*t); y = hilbert(x); plot(t(1:150),real(y(1:150))), hold on plot(t(1:150),imag(y(1:150)), : ), hold off A=abs(y); phi=(unwrap(2*atan(imag(y)./real(y))))/2; plot(t(1:150),a(1:150)) plot(t(1:150),phi(1:150)) f=1/(2*pi)*diff(phi)/(t(2)-t(1)); plot(t(1:1024/2),f(1:1024/2)) Note that the Matlab call hilbert( ) returns the analytic signal, z(t), not the Hilbert transform. The Hilbert transform is obtained as the imaginary part of the result returned by hilbert( ).