24
8/12/2019 Spectral Analysis Basics http://slidepdf.com/reader/full/spectral-analysis-basics 1/24 From http://www.mathworks.com/access/helpdesk/help/toolbox/signal/signal.shtml Spectral Analysis The goal of spectral estimation is to describe the distribution (over frequency of the power contained in a signal! based on a finite set of data. "stimation of power spectra is useful in a variety of applications! including the detection of signals buried in wide#band noise. The power spectrum of a stationary random process  x n  is mathematically related to the correlation sequence by the discrete#time Fourier transform. $n terms of normali%ed frequency! this is given by This can be written as a function of physical frequency  (e.g.! in hert% by using the relation & ' /s ! where s  is the sampling frequency. The correlation sequence can be derived from the power spectrum by use of the inverse discrete#time Fourier transform: The average power of the sequence x n  over the entire yquist interval is represented by The quantities from the above expression are defined as the power spectral density  ()*+ of the stationary random signal  x n . The average power of a signal over a particular frequency band ! ! can be found by integrating the )*+ over that band: ,ou can see from the above expression that xx ( represents the power content of a signal in an infinitesimal  frequency band! which is why we call it the power spectral density . The units of the )*+ are power (e.g.! watts per unit of frequency. $n the case of xx ( ! this is watts/rad/sample or simply watts/rad. $n the case of xx (! the units are watts/hert%. $ntegration of the )*+ with respect to frequency yields units of watts! as expected for the average power . For real signals! the )*+ is symmetric about +-! and thus xx ( for is sufficient to completely characteri%e the )*+. owever! in order to obtain the average power over the entire yquist interval it is necessary to introduce the concept of the one-sided  )*+. The one#sided )*+ is given by 1

Spectral Analysis Basics

Embed Size (px)

Citation preview

Page 1: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 1/24

From http://www.mathworks.com/access/helpdesk/help/toolbox/signal/signal.shtml

Spectral Analysis

The goal of spectral estimation is to describe the distribution (over frequency of the power contained in a signal!based on a finite set of data. "stimation of power spectra is useful in a variety of applications! including the detection ofsignals buried in wide#band noise.

The power spectrum of a stationary random process x n is mathematically related to the correlation sequence by thediscrete#time Fourier transform. $n terms of normali%ed frequency! this is given by

This can be written as a function of physical frequency f  (e.g.! in hert% by using the relation & ' f /f s! where f s is thesampling frequency.

The correlation sequence can be derived from the power spectrum by use of the inverse discrete#time Fouriertransform:

The average power of the sequence x n over the entire yquist interval is represented by

The quantities

from the above expression are defined as the power spectral density  ()*+ of the stationary random signal x n.

The average power of a signal over a particular frequency band ! ! can be found byintegrating the )*+ over that band:

,ou can see from the above expression that P xx( represents the power content of a signal in an infinitesimal  frequency band! which is why we call it the power spectral density .

The units of the )*+ are power (e.g.! watts per unit of frequency. $n the case of P xx( ! this is watts/rad/sample orsimply watts/rad. $n the case of P xx(f ! the units are watts/hert%. $ntegration of the )*+ with respect to frequency yields

units of watts! as expected for the average power .

For real signals! the )*+ is symmetric about +-! and thus P xx( for is sufficient to completelycharacteri%e the )*+. owever! in order to obtain the average power over the entire yquist interval it is necessary tointroduce the concept of the one-sided  )*+.

The one#sided )*+ is given by

1

Page 2: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 2/24

The average power of a signal over the frequency band ! ! can be computed using theone#sided )*+ as

Spectral Estimation Method

The various methods of spectrum estimation available in the *ignal )rocessing Toolbox can be categori%ed as follows:

onparametric methods )arametric methods *ubspace methods 

Nonparametric methods are those in which the estimate of the )*+ is made directly from the signal itself. The simplestsuch method is the periodogram. n improved version of the periodogram is Welch's method  012. more modernnonparametric technique is the multitaper method  (3T3.

Parametric methods are those in which the signal whose )*+ we want to estimate is assumed to be output of a linearsystem driven by white noise. "xamples are the Yule-Walker autoregressive (4 method  and the Burg method .These methods estimate the )*+ by first estimating the parameters (coefficients of the linear system thathypothetically 5generates5 the signal. They tend to produce better results than classical nonparametric methods whenthe data length of the available signal is relatively short.

Suspace methods! also known as high-resolution methods or super-resolution methods! generate frequencycomponent estimates for a signal based on an eigenanalysis or eigendecomposition of the correlation matrix."xamples are the multiple signal classification (36*$- method  or the eigenvector ("7 method . These methods arebest suited for line spectra # that is! spectra of sinusoidal signals # and are effective in the detection of sinusoids buriedin noise! especially when the signal to noise ratios are low.

 ll three categories of methods are listed in the table below with the corresponding toolbox function names. 3oreinformation about each function is on the corresponding function reference page. *ee )arametric 3odeling for detailsabout lpc and other parametric estimation functions.

Method +escription Functions

)eriodogram )ower spectral density estimate periodogram

8elch veraged periodograms of overlapped! windowed signal sections pwelch! csd! tfe!cohere

3ultitaper *pectral estimate from combination of multiple orthogonal windows (or5tapers5

pmtm

,ule#8alker 4 utoregressive (4 spectral estimate of a time#series from its estimatedautocorrelation function

pyulear 

9urg utoregressive (4 spectral estimation of a time#series by minimi%ation oflinear prediction errors

pburg

-ovariance utoregressive (4 spectral estimation of a time#series by minimi%ation of theforward prediction errors

pcov

3odified-ovariance

 utoregressive (4 spectral estimation of a time#series by minimi%ation of theforward and backward prediction errors

pmcov

2

Page 3: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 3/24

36*$- 3ultiple signal classification pmusic

"igenvector )seudospectrum estimate peig

Nonparametric Methods

The following sections discuss the periodogram! modified periodogram! 8elch! and multitaper  methods ofnonparametric estimation! along with the related -*+ function! transfer function estimate! and coherence function.

Periodogram. ne way of estimating the power spectrum of a process is to simply find the discrete#time Fouriertransform of the samples of the process (usually done on a grid with an FFT and take the magnitude squared ofthe result. This estimate is called the periodogram.

The periodogram estimate of the )*+ of a length#; signal x ;0n2 is

where

The actual computation of ! ;(f  can be performed only at a finite number of frequency points! N ! and usually employsthe FFT. $n practice! most implementations of the periodogram method compute the N #point )*+ estimate

where

$t is wise to choose N  < " so that N  is the next power of two larger than ". To evaluate ! ;0f k2! we simply pad x ;0n2 with%eros to length N . $f " < N ! we must wrap x ;0n2 modulo#N  prior to computing ! ;0f k2.

 s an example! consider the following =>>=#element signal xn! which consists of two sinusoids plus noise:

randn('state',0);fs !000; " Sampling fre#$encyt (0%fs)&fs; " ne second orth of samplesA ! *+; " Sin$soid amplit$des (ro ector)f !-0;!0+; " Sin$soid fre#$encies (col$mn ector)/n Asin(*pift) 1 0.!randn(si2e(t));

ote The three last lines illustrate a convenient and general way to express the sum of sinusoids. Together

they are equivalent to

  xn & sin('?pi?=@>?t A '?sin('?pi?=B>?t A >.=?randn(si%e(tC

The periodogram estimate of the )*+ can be computed by

P// periodogram(/n,+,'tosided',!0*,fs); " second arg is indo

PE34563AM(7, 84N58, 9tosided9, N::, :s) returns a two#sided )*+ of a real signal D. 8$+8 must bea vector of the same length as D. $f 8$+8 is a window other than a boxcar (rectangular! the resulting estimate is amodified periodogram. $f 8$+8 is specified as empty! the default window (boxcar is used. $n this case! )xx will

3

Page 4: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 4/24

have length FFT and will be computed over the interval 0>!'?)i if Fs (sampling frequency is not specified and overthe interval 0>!Fs if Fs is specified. lternatively! the string EtwosidedE can be replaced with the string EonesidedE for areal signal D. The string EtwosidedE or EonesidedE may be placed in any position in the input argument list after8$+8. FFT specifies the number of FFT points used to calculate the )*+ estimate. For real D! )xx has length(FFT/'A= if FFT is even! and (FFTA=/' if FFT is odd. For complex D! )xx always has length FFT. $f FFT isspecified as empty! the default FFT is used (FFT of length given by the larger of '@ and the next power of ' greaterthan the length of D.

and a plot of the estimate can be displayed by simply omitting the output argument! as below:

periodogram(/n,+,'tosided',!0*,fs);

The average power can be computed by approximating the integral with the following sum:

Po (fs&length(P//)) s$m(P//))ow & '.@>'1

,ou can also compute the average power from the one#sided )*+ estimate:

P//o periodogram(/n,+,!0*,fs);Po (fs&(*length(P//o))) s$m(P//o)

)ow & '.BGHG

Performance of the Periodogram. The following sections discuss the performance of the periodogram with regard tothe issues of lea<age! resol$tion! =ias! and ariance.

Spectral >ea<age. -onsider the power spectrum or )*+ of a finite#length signal x ;0n2! as discussed in the)eriodogram. $t is frequently useful to interpret x ;0n2 as the result of multiplying an infinite signal! x 0n2! by a finite#lengthrectangular window! w 40n2:

9ecause multiplication in the time domain corresponds to convolution in the frequency domain! the Fourier transformof the expression above is

The expression developed earlier for the periodogram!

4

Page 5: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 5/24

illustrates that the periodogram is also influenced by this convolution.

The effect of the convolution is best understood for sinusoidal data. *uppose that  x 0n2 is composed of a sum of #  complex sinusoids:

$ts spectrum is

which for a finite#length sequence becomes

*o in the spectrum of the finite#length signal! the +irac deltas have been replaced by terms of the form !which corresponds to the frequency response of a rectangular window centered on the frequency f k.The frequency response of a rectangular window has the shape of a sinc signal! as shown below.

/n ones(-0,!)',2eros(-0,!)'+;plot(/n);

periodogram(/n, +, 'tosided', !0*, !000);

5

Page 6: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 6/24

The plot displays a main lobe and several side lobes! the largest of which is approximately =I.@ d9 below the mainlobepeak. These lobes account for the effect known as spectral leakage. 8hile the infinite#length signal has its power

concentrated exactly at the discrete frequency points f k! the windowed (or truncated signal has a continuum of power5leaked5 around the discrete frequency points f k.

9ecause the frequency response of a short rectangular window is a much poorer approximation to the +irac deltafunction than that of a longer window! spectral leakage is especially evident when data records are short. -onsider thefollowing sequence of =>> samples:

fs !000; " Sampling fre#$encyt (0%fs&!0)&fs; " ne?tenth of a second orth of samples

A ! *+; " Sin$soid amplit$desf !-0;!0+; " Sin$soid fre#$encies/n Asin(*pift);plot(/n);

periodogram(/n,+,!0*,fs);

6

Page 7: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 7/24

ote that where we expect two frequency spikes at =B> and =@> % and nothing else! we see side lobes where we

have leakage due to the finite length of the data.

$t is important to note that the effect of spectral leakage is contingent solely on the length of the data record. $t is not  aconsequence of the fact that the periodogram is computed at a finite number of frequency samples.

3esol$tion. $esolution refers to the ability to discriminate spectral features! and is a key concept on the analysis ofspectral estimator performance.

$n order to resolve two sinusoids that are relatively close together in frequency! it is necessary for the differencebetween the two frequencies to be greater than the width of the mainlobe of the leaked spectra for either one of thesesinusoids. The mainlobe width is defined to be the width of the mainlobe at the point where the power is half the peakmainlobe power (i.e.! I d9 width. This width is approximately equal to f s / ". $n other words! for two sinusoids offrequencies f = and f '! the resolvability condition requires that

$n the example above! where two sinusoids are separated by only => %! the data record must be greater than =>>samples to allow resolution of two distinct sinusoids by a periodogram. -onsider a case where this criterion is notmet! as for the sequence of H samples below:

randn('state',0) " 8e ill add some random noise in alsofs !000; " Sampling fre#$encyt (0%fs&!-).&fs; " @ samplesA ! *+; " Sin$soid amplit$desf !-0;!0+; " Sin$soid fre#$encies/n Asin(*pift) 1 0.!randn(si2e(t));

plot(/n);

7

Page 8: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 8/24

periodogram(/n,+,!0*,fs);

ote here we have lost the separate frequency peaks for the =B> and =@> % sinusoids as they are lumped togetherinto a broad frequency peak.

The above discussion about resolution did not consider the effects of noise since the signal#to#noise ratio (*4 hasbeen relatively high thus far. 8hen the *4 is low! true spectral features are much harder to distinguish! and noiseartifacts appear in spectral estimates based on the periodogram. The example below illustrates this:

randn('state',0)fs !000;t (0%fs&!0).&fs; " Bac< to !00 samplesA ! *+;f !-0;!0+;/n Asin(*pift) 1 *randn(si2e(t)); " >arger amplit$de of noiseplot(/n);

8

Page 9: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 9/24

periodogram(/n,+,!0*,fs);

ote here we have again lost the separate frequency peaks for the =B> and =@> % sinusoids as they are lumpedtogether into a broad frequency peak! but this time due to the magnitude of the noise present.

Bias of the Periodogram.  The periodogram is a biased estimator of the )*+. $ts expected value can be shown to be

which is similar to the first expression for ! ;(f  in *pectral ;eakage! except that the expression here is in terms ofaverage power rather than magnitude. This suggests that the estimates produced by the periodogram correspond to a

leaky  )*+ rather than the true )*+.

ote that essentially yields a triangular 9artlett window (which is apparent from the fact that theconvolution of two rectangular pulses is a triangular pulse. This results in a height for the largest sidelobes of theleaky power spectra that is about 'H d9 below the mainlobe peakC i.e.! about twice the frequency separation relative tothe non#squared rectangular window.

The periodogram is asymptotically unbiased! which is evident from the earlier observation that as the data recordlength tends to infinity! the frequency response of the rectangular window more closely approximates the +irac delta

9

Page 10: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 10/24

function (also true for a 9artlett window. owever! in some cases the periodogram is a poor estimator of the )*+even when the data record is long. This is due to the variance of the periodogram! as explained below.

Cariance of the Periodogram.  The variance of the periodogram can be shown to be approximately

which indicates that the variance does not tend to %ero as the data length " tends to infinity. $n statistical terms! theperiodogram is not a consistent estimator of the )*+. evertheless! the periodogram can be a useful tool for spectralestimation in situations where the *4 is high! and especially if the data record is long.

he Modified Periodogram  The modified periodogram windows the time#domain signal prior to computing the FFTin order to smooth the edges of the signal. This has the effect of reducing the height of the sidelobes or spectralleakage. This phenomenon gives rise to the interpretation of sidelobes as spurious frequencies introduced intothe signal by the abrupt truncation that occurs when a rectangular window is used. For nonrectangular windows!the end points of the truncated signal are attenuated smoothly! and hence the spurious frequencies introducedare much less severe. n the other hand! nonrectangular windows also broaden the mainlobe! which results in anet reduction of resolution.

The periodogram function allows you to compute a modified periodogram by specifying the window to be used on thedata. For example! compare a rectangular window and a amming window:

randn('state',0)fs !000; " Sampling fre#$encyt (0%fs&!0).&fs; " ne?tenth of a second orth of samplesA ! *+; " Sin$soid amplit$desf !-0;!0+; " Sin$soid fre#$encies/n Asin(*pift) 1 0.!randn(si2e(t));periodogram(/n,rectin(length(/n)),!0*,fs);

periodogram(/n,hamming(length(/n)),!0*,fs);

10

Page 11: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 11/24

,ou can verify that although the sidelobes are much less evident in the amming#windowed periodogram! the twomain peaks are wider. $n fact! the I d9 width of the mainlobe corresponding to a amming window is approximately

twice that of a rectangular window. ence! for a fixed data length! the )*+ resolution attainable with a ammingwindow is approximately half that attainable with a rectangular window. The competing interests of mainlobe width andsidelobe height can be resolved to some extent by using variable windows such as the Jaiser window.

onrectangular windowing affects the average power of a signal because some of the time samples are attenuatedwhen multiplied by the window. To compensate for this! the periodogram function normali%es the window to have anaverage power of unity. This way the choice of window does not affect the average power of the signal.The modified periodogram estimate of the )*+ is

where %  is the window normali%ation constant

which is independent of the choice of window. The addition of %  as a normali%ation constant ensures that the modifiedperiodogram is asymptotically unbiased.

8elch's Method  n improved estimator of the )*+ is the one proposed by 8elch D+. The method consists ofdividing the time series data into (possibly overlapping segments! computing a modified periodogram of eachsegment! and then averaging the )*+ estimates. The result is 8elchEs )*+ estimate.

8elchEs method is implemented in the *ignal )rocessing Toolbox by the pwelch function. 9y default! the data isdivided into eight segments with @>K overlap between them. amming window is used to compute the modified

periodogram of each segment. The averaging of modified periodograms tends to decrease the variance of theestimate relative to a single periodogram estimate of the entire data record. lthough overlap between segments tendsto introduce redundant information! this effect is diminished by the use of a nonrectangular window! which reduces theimportance or weight  given to the end samples of segments (the samples that overlap.

owever! as mentioned above! the combined use of short data records and nonrectangular windows results inreduced resolution of the estimator. $n summary! there is a tradeoff between variance reduction and resolution. necan manipulate the parameters in 8elchEs method to obtain improved estimates relative to the periodogram! especiallywhen the *4 is low. This is illustrated in the following example. -onsider an original signal consisting of I>=samples:

11

Page 12: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 12/24

randn('state',!)fs !000; " Sampling fre#$encyt (0%0.fs).&fs; " 0! samplesA * D+; " Sin$soid amplit$des (ro ector)f !-0;!0+; " Sin$soid fre#$encies (col$mn ector)/n Asin(*pift) 1 -randn(si2e(t));periodogram(/n,rectin(length(/n)),!0*,fs);

8e can obtain 8elchEs spectral estimate for I segments with @>K overlap with

pelch(/n,rectin(!-0),-,-!*,fs);

$n the periodogram above! noise and the leakage make one of the sinusoids essentially indistinguishable from theartificial peaks. $n contrast! although the )*+ produced by 8elchEs method has wider peaks! you can still distinguishthe two sinusoids! which stand out from the 5noise floor.5 owever! if we try to reduce the variance further! the loss ofresolution causes one of the sinusoids to be lost altogether:

pelch(/n,hamming(!00),-,-!*,fs);

12

Page 13: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 13/24

For a more detailed discussion of 8elchEs method of )*+ estimation! see Jay 0'2 and 8elch 012.

Bias and Normali2ation in 8elch's Method. 8elchEs method yields a biased estimator of the )*+. The expected

value can be found to be

where "s is the length of the data segments and %  is the same normali%ation constant present in the definition of themodified periodogram. s is the case for all periodograms! 8elchEs estimator is asymptotically unbiased. For a fixedlength data record! the bias of 8elchEs estimate is larger than that of the periodogram because "s L ".

The variance of 8elchEs estimator is difficult to compute because it depends on both the window used and the amountof overlap between segments. 9asically! the variance is inversely proportional to the number of segments whosemodified periodograms are being averaged.

M$ltitaper Method. The periodogram can be interpreted as filtering a length " signal! x ;0n2! through a filter bank (a setof filters in parallel of " F$4 bandpass filters. The I d9 bandwidth of each of these bandpass filters can be shown tobe approximately equal to f s / ". The magnitude response of each one of these bandpass f ilters resembles that of therectangular window discussed in *pectral ;eakage. The periodogram can thus be viewed as a computation of thepower of each filtered signal (i.e.! the output of each bandpass filter that uses Must one sample of each filtered signaland assumes that the )*+ of x ;0n2 is constant over the bandwidth of each bandpass filter.

 s the length of the signal increases! the bandwidth of each bandpass filter decreases! making it a more selectivefilter! and improving the approximation of constant )*+ over the bandwidth of the filter. This provides anotherinterpretation of why the )*+ estimate of the periodogram improves as the length of the signal increases. owever!there are two factors apparent from this standpoint that compromise the accuracy of the periodogram estimate. First!the rectangular window yields a poor bandpass filter. *econd! the computation of the power at the output of eachbandpass filter relies on a single sample of the output signal! producing a very crude approximation.

8elchEs method can be given a similar interpretation in terms of a filter bank. $n 8elchEs implementation! severalsamples are used to compute the output power! resulting in reduced variance of the estimate. n the other hand! thebandwidth of each bandpass filter is larger than that corresponding to the periodogram method! which results in a lossof resolution. The filter bank model thus provides a new interpretation of the compromise between variance andresolution.

ThompsonEs multitaper method  (3T3 builds on these results to provide an improved )*+ estimate. $nstead of usingbandpass filters that are essentially rectangular windows (as in the periodogram method! the 3T3 method uses abank of optimal bandpass filters to compute the estimate. These optimal F$4 filters are derived from a set ofsequences known as discrete prolate spheroidal se&uences (+)**s! also known as Slepian se&uences.

13

Page 14: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 14/24

$n addition! the 3T3 method provides a time#bandwidth parameter with which to balance the variance and resolution.This parameter is given by the time#bandwidth product! NW and it is directly related to the number of tapers used tocompute the spectrum. There are always '?NW #= tapers used to form the estimate. This means that! as NW  increases!there are more estimates of the power spectrum! and the variance of the estimate decreases. owever! the bandwidthof each taper is also proportional to NW ! so as NW  increases! each estimate exhibits more spectral leakage (i.e.! widerpeaks and the overall spectral estimate is more biased. For each data set! there is usually a value for NW  that allowsan optimal trade#off between bias and variance.

The *ignal )rocessing Toolbox function that implements the 3T3 method is called pmtm. 6se pmtm to compute the)*+ of xn from the previous examples:

randn('state',0)fs !000; " Sampling fre#$encyt (0%fs)&fs; " ne second orth of samplesA ! *+; " Sin$soid amplit$desf !-0;!0+; " Sin$soid fre#$encies/n Asin(*pift) 1 0.!randn(si2e(t));P,:+ pmtm(/n,,!0*,fs);plot(:,!0log!0(P)) " Plot in dB&F2/la=el(':re#$ency (F2)');yla=el('Poer Spectral 5ensity (dB&F2)');

ere we also see a more accurate detection of the frequencies (=B> and =@> %.

9y lowering the time#bandwidth product! you can increase the resolution at the expense of larger variance:

P!,f+ pmtm(/n,&*,!0*,fs);plot(f,!0log!0(P!))/la=el(':re#$ency (F2)');

yla=el('Poer Spectral 5ensity (dB&F2)');

14

Page 15: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 15/24

ote that the average power is conserved in both cases:

Po (fs&!0*) s$m(P))ow & '.BG'

Po! (fs&!0*) s$m(P!))ow= & '.BG'H

This method is more computationally expensive than 8elchEs method due to the cost of computing the discrete prolatespheroidal sequences. For long data series (=>!>>> points or more! it is useful to compute the +)**s once and savethem in a 3T#file. The 3#files dpsssave! dpssload! dpssdir! and dpssclear are provided to keep a database of saved+)**s in the 3T#file dpss.mat.

Gross?Spectral 5ensity :$nction. The )*+ is a special case of the cross spectral density  (-*+ function! definedbetween two signals x n and y n as

 s is the case for the correlation and covariance sequences! the toolbox estimates the )*+ and -*+ because signallengths are finite. To estimate the cross#spectral density of two equal length signals x and y using 8elchEs method! thecsd function forms the periodogram as the product of the FFT of x and the conMugate of the FFT of y. 6nlike the real#valued )*+! the -*+ is a complex function. csd handles the sectioning and windowing of x and y in the same way asthe pwelch function: *xy & csd(x!y!nfft!fs!window!numoverlap

Gonfidence 4nterals. ,ou can compute confidence intervals using the csd function by including an additional inputargument p that specifies the percentage of the confidence interval! and setting the numoverlap argument to >:0*xy!*xyc!f2 & csd(x!y!nfft!fs!window!>!p p must be a scalar between > and =. This function assumes chi#squareddistributed periodograms of the nonoverlapping sections of windowed data in computing the confidence intervals. This

assumption is valid when the signal is a Naussian distributed random process. )rovided these assumptions arecorrect! the confidence interval 0*xy#*xyc(:!= *xyA*xyc(:!'2 covers the true -*+ with probability p. $f you setnumoverlap to any value other than >! you generate a warning indicating that the sections overlap and the confidenceinterval is not reliable.

ransfer :$nction Estimate. ne application of 8elchEs method is nonparametric system identification. ssume that  is a linear! time invariant system! and x (n and y (n are the input to and output of  ! respectively. Then the powerspectrum of x (n is related to the -*+ of x (n and y (n by

 n estimate of the transfer function between x (n and y (n is

15

Page 16: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 16/24

This method estimates both magnitude and phase information. The tfe function uses 8elchEs method to compute the-*+ and power spectrum! and then forms their quotient for the transfer function estimate. 6se tfe the same way thatyou use the csd function. Filter the signal xn with an F$4 filter! then plot the actual magnitude response and theestimated response:

h ones(!,!0)&!0; " Moing?aerage filter 

yn filter(h,!,/n);FES,f+ tfe(/n,yn,*-@,fs,*-@,!*D,'none');F fre#2(h,!,f,fs);s$=plot(*,!,!); plot(f,a=s(F));title('Act$al ransfer :$nction Magnit$de');

s$=plot(*,!,*); plot(f,a=s(FES));title('ransfer :$nction Magnit$de Estimate');/la=el(':re#$ency (F2)');

Goherence :$nction. The magnitude#squared coherence between two signals x (n and y (n is

This quotient is a real number between > and = that measures the correlation between x (n and y (n at the frequency. The cohere function takes sequences x and y! computes their power spectra and -*+! and returns the quotient of

the magnitude squared of the -*+ and the product of the power spectra. $ts options and operation are similar to thecsd and tfe functions. The coherence function of xn and the filter output yn versus frequency is

cohere(/n,yn,*-@,fs,*-@,!*D,'none')

16

Page 17: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 17/24

$f the input sequence length nfft! window length window! and the number of overlapping data points in a windownumoverlap! are such that cohere operates on only a single record! the function returns all ones. This is because thecoherence function for linearly dependent data is one.

Parametric PS5 Methods.  )arametric methods can yield higher resolutions than nonparametric methods in caseswhen the signal length is short. These methods use a different approach to spectral estimationC instead of trying to

estimate the )*+ directly from the data! they model  the data as the output of a linear system driven by white noise!and then attempt to estimate the parameters of that linear system.

The most commonly used linear system model is the all-pole model ! a filter with all of its %eroes at the origin in the ( #plane. The output of such a filter for white noise input is an autoregressive (4 process. For this reason! thesemethods are sometimes referred to as )$ methods of spectral estimation.

The 4 methods tend to adequately describe spectra of data that is 5peaky!5 that is! data whose )*+ is large atcertain frequencies. The data in many practical applications (such as speech tends to have 5peaky spectra5 so that

 4 models are often useful. $n addition! the 4 models lead to a system of linear equations which is relatively simpleto solve.

The *ignal )rocessing Toolbox offers the following 4 methods for spectral estimation:

,ule#8alker 4 method (autocorrelation method 9urg method -ovariance method 3odified covariance method 

 ll 4 methods yield a )*+ estimate given by

The different 4 methods estimate the 4 parameters ap(k  slightly differently! yielding different )*+ estimates. The

following table provides a summary of the different 4 methods.

17

Page 18: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 18/24

9urg -ovariance 3odified-ovariance

,ule#8alker 

-haracteristics +oes not apply window todata

+oes not applywindow to data

+oes not applywindow to data

 pplies window to data

3inimi%es the forward andbackward prediction errors

in the least squares sense!with the 4 coefficientsconstrained to satisfy the ;#+ recursion

3inimi%es theforward prediction

error in the leastsquares sense

3inimi%es theforward and

backward predictionerrors in the leastsquares sense

3inimi%es the forwardprediction error in the least

squares sense(also called 5utocorrelationmethod5

 dvantages igh resolution for shortdata records

9etter resolutionthan ,#8 for shortdata records (moreaccurate estimates

igh resolution forshort data records

)erforms as well as othermethods for large datarecords

 lways produces a stablemodel

 ble to extractfrequencies fromdata consisting of por more pure

sinusoids

 ble to extractfrequencies fromdata consisting of por more pure

sinusoids

 lways produces a stablemodel

+oes not sufferspectral line#splitting

+isadvantages )eak locations highlydependent on initial phase

3ay produceunstable models

3ay produceunstable models

)erforms relatively poorlyfor short data records

3ay suffer spectral line#splitting for sinusoids innoise! or when order is verylarge

Frequency bias forestimates ofsinusoids in noise

)eak locationsslightly dependenton initial phase

Frequency bias forestimates of sinusoids innoise

Frequency bias forestimates of sinusoids innoise

3inor frequencybias for estimates ofsinusoids in noise

-onditions foronsingularity

rder must be lessthan or equal tohalf the input framesi%e

rder must be lessthan or equal to '/Ithe input frame si%e

9ecause of the biasedestimate! theautocorrelation matrix isguaranteed to positive#definite! hence nonsingular 

 H$le?8al<er A3 Method. The Yule-Walker AR method  of spectral estimation computes the 4 parameters byforming a biased estimate of the signalEs autocorrelation function! and solving the least squares minimi%ation of theforward prediction error. This results in the ,ule#8alker equations.

The use of a biased estimate of the autocorrelation function ensures that the autocorrelation matrix above is positivedefinite. ence! the matrix is invertible and a solution is guaranteed to exist. 3oreover! the 4 parameters thuscomputed always result in a stable all#pole model. The ,ule#8alker equations can be solved efficiently via ;evinsonEs

18

Page 19: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 19/24

algorithm! which takes advantage of the Toeplit% structure of the autocorrelation matrix. The toolbox function pyulearimplements the ,ule#8alker 4 method. For example! compare the spectrum of a speech signal using 8elchEsmethod and the ,ule#8alker 4 method:

load mtl=; " speech signal dataplot(mtl=(!%-!*);

P!,f+ pelch(mtl=,hamming(*-@),!*D,!0*,fs);P*,f+ py$lear(mtl=,!,!0*,fs);plot(f,!0log!0(P!),'%',f,!0log!0(P*)); gridyla=el('PS5 Estimates (dB&F2)');/la=el(':re#$ency (F2)');legend('8elch','H$le?8al<er A3')

The solid#line ,ule#8alker 4 spectrum is smoother than the periodogram because of the simple underlying all#polemodel.

B$rg Method.  The 9urg method for 4 spectral estimation is based on minimi%ing the forward and backwardprediction errors while satisfying the ;evinson#+urbin recursion (see 3arple 0I2! -hapter H! and )roakis 02!*ection ='.I.I. $n contrast to other 4 estimation methods! the 9urg method avoids calculating the autocorrelationfunction! and instead estimates the reflection coefficients directly.

The primary advantages of the 9urg method are resolving closely spaced sinusoids in signals with low noise levels!and estimating short data records! in which case the 4 power spectral density estimates are very close to the truevalues. $n addition! the 9urg method ensures a stable 4 model and is computationally efficient.

19

Page 20: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 20/24

The accuracy of the 9urg method is lower for high#order models! long data records! and high signal#to#noise ratios(which can cause line splitting ! or the generation of extraneous peaks in the spectrum estimate. The spectral densityestimate computed by the 9urg method is also susceptible to frequency shifts (relative to the true frequency resultingfrom the initial phase of noisy sinusoidal signals. This effect is magnified when analy%ing short data sequences. Thetoolbox function pburg implements the 9urg method. -ompare the spectrum of the speech signal generated by boththe 9urg method and the ,ule#8alker 4 method. They are very similar for large signal lengths:

load mtl=P!,f+ p=$rg(mtl=(!%-!*),!,!0*,fs); " !th order modelP*,f+ py$lear(mtl=(!%-!*),!,!0*,fs); " !th order modelplot(f,!0log!0(P!),'%',f,!0log!0(P*)); gridyla=el('Magnit$de (dB)'); /la=el(':re#$ency (F2)');legend('B$rg','H$le?8al<er A3'

-ompare the spectrum of a noisy signal computed using the 9urg method and the 8elch method:

randn('state',0)

fs !000; " Sampling fre#$encyt (0%fs)&fs; " ne second orth of samplesA ! *+; " Sin$soid amplit$desf !-0;!0+; " Sin$soid fre#$encies/n Asin(*pift) 1 0.!randn(si2e(t));P!,f+ pelch(/n,hamming(*-@),!*D,!0*,fs);P*,f+ p=$rg(/n,!,!0*,fs);plot(f,!0log!0(P!),'%',f,!0log!0(P*)); gridyla=el('PS5 Estimates (dB&F2)');/la=el(':re#$ency (F2)');legend('8elch','B$rg')

20

Page 21: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 21/24

ote that! as the model order for the 9urg method is reduced! a frequency shift due to the initial phase of the sinusoidswill become apparent.

Goariance and Modified Goariance Methods. The covariance method for 4 spectral estimation is based on

minimi%ing the forward prediction error. The modified covariance method is based on minimi%ing the forward andbackward prediction errors. The toolbox functions pcov and pmcov implement the respective methods. -ompare thespectrum of the speech signal generated by both the covariance method and the modified covariance method. Theyare nearly identical! even for a short signal length:

load mtl=P!,f+ pco(mtl=(!%@),!,!0*,fs); " !th order modelP*,f+ pmco(mtl=(!%@),!,!0*,fs); " !th order modelplot(f,!0log!0(P!),'%',f,!0log!0(P*)); gridyla=el('Magnit$de (dB)'); /la=el(':re#$ency (F2)');legend('Goariance','Modified Goariance')

MIS4G and Eigenector Analysis Methods. The pmusic and peig functions provide two related spectral analysismethods: pmusic provides the multiple signal classification (36*$- method developed by *chmidt! while peigprovides the eigenvector ("7 method developed by Oohnson. *ee 3arple 0I2 (pgs. IHI#IH1 for a summary of thesemethods.

21

Page 22: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 22/24

9oth of these methods are frequency estimator techniques based on eigenanalysis of the autocorrelation matrix. Thistype of spectral analysis categori%es the information in a correlation or data matrix! assigning information to either asignal subspace or a noise subspace.

Eigenanalysis erie.  -onsider a number of complex sinusoids embedded in white noise. ,ou can write theautocorrelation matrix $  for this system as the sum of the signal autocorrelation matrix (S and the noiseautocorrelation matrix (W :

There is a close relationship between the eigenvectors of the signal autocorrelation matrix and the signal and noise

subspaces. The eigenvectors v  of S span the same signal subspace as the signal vectors. $f the system contains #  complex sinusoids and the order of the autocorrelation matrix is p! eigenvectors v # A= through v  pA= span the noisesubspace of the autocorrelation matrix.

:re#$ency Estimator :$nctions.  To generate their frequency estimates! eigenanalysis methods calculate functionsof the vectors in the signal and noise subspaces. 9oth the 36*$- and "7 techniques choose a function that goes toinfinity (denominator goes to %ero at one of the sinusoidal frequencies in the input signal. 6sing digital technology! theresulting estimate has sharp peaks at the frequencies of interestC this means that there might not be infinity values inthe vectors. The 36*$- estimate is given by the formula

where N  is the si%e of the eigenvectors and e(f  is a vector of complex sinusoids.

v represents the eigenvectors of the input signalEs correlation matrixC vk is the k th eigenvector.   is the conMugatetranspose operator. The eigenvectors used in the sum correspond to the smallest eigenvalues and span the noisesubspace ( p is the si%e of the signal subspace.

The expression is equivalent to a Fourier transform (the vector e(f  consists of complex exponentials. Thisform is useful for numeric computation because the FFT can be computed for each vk and then the squaredmagnitudes can be summed.The "7 method weights the summation by the eigenvalues of the correlation matrix:

The pmusic and peig functions in this toolbox use the svd (singular value decomposition function in the signal caseand the eig function for analy%ing the correlation matrix and assigning eigenvectors to the signal or noise subspaces.8hen svd is used! pmusic and peig never compute the correlation matrix explicitly! but the singular values are theeigenvalues.

randn('state',0);fs !000; " Sampling fre#$encyt (0%fs)&fs; " ne second orth of samplesA ! *+; " Sin$soid amplit$des (ro ector);f !-0;!0+; " Sin$soid fre#$encies (col$mn ector)/n Asin(*pift) 1 0.!randn(si2e(t));periodogram(/n,+,!0*,fs);

22

Page 23: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 23/24

7*corrmt/(/n,*0,'co'); " Estimate the correlation matri/ $sing the coariance method.pm$sic(7*,,fs) " Ise tice the signal space dimension for real sin$soids.

peig(7*,,fs);

23

Page 24: Spectral Analysis Basics

8/12/2019 Spectral Analysis Basics

http://slidepdf.com/reader/full/spectral-analysis-basics 24/24