54
Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

  • View
    225

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Lecture 18

advanced topics is spectral analysis

Parsival’s Theorem

Multi-taper spectral analysis

Auto- and Cross- Correlation

Phase spectra

Page 2: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Parsival’s Theorem

Total power in the time-series

Total power its spectrum

i Ti2 i |Ci|2

Discrete Version

T(t)2 dt

|C()|2 d

Integral Version

Page 3: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Write the inverse DFT as Gm=d,

where the data dk=Tk are the timeseries, and

the unknowns, mk=Ck, are the Fourier coefficients, and

G is N-1 times the matrix of complex exponentials

Recall that GHG=N-1I

Note dHd = (Gm)H(Gm) = mH(GHG)m = N-1 mHm

Or i Ti2 = N-1 i |Ci|2 ….. Parsival’s Theorem

Page 4: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Multi-taper spectral analysis

Page 5: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

A criticism of the Hamming Taper is that you’re throwing away ‘hard-earned’ data at the ends of the interval, because

the taper is near-zero there …

Multi-taper spectral analysis offers a way to ‘save’ that data

Page 6: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Let’s try to design a good taper

A good taper …

has a fourier transform with …

a lot of energy in an interval near =0

compared to the intervals far from =0

Page 7: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

So try the formal maximization problem:find taper coefficients, Ti i=0, N-1

with Fourier coefficents C() that maximize the ratio of the energy near =0, say

-W<<W (green interval) to the total energy (green plus red intervals)

R = -WW |Ci|2 d / -ny

ny |Ci|2 d

Here 2W is the width of the near =0 (green) interval

WW

Page 8: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

R = -WW |Ci|2 d / -ny

ny |Ci|2 d

Note that the denominator is proportional to i=0N Ti

2 by Parsival’s Theorem.

So we can rewrite the problem

Maximize R = -WW |Ci|2 d

Subject to the constraint that the power in the timeseries is a constant, say unity

i=0N Ti

2 = 1

Page 9: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

R = -WW |C|2 d = -W

W Ci* Ci

d

But C() = n=-N/2N/2 Tn exp(-i nt ) and

C*() = m=-N/2N/2 Tm exp(+i mt )

R = -WW Ck

* Ck d =

n m Tn Tm -W

W exp{ i(m-n) t } d

n m Tn Tm Mnm with Mnm = -W

W exp{ i(m-n) t } d

Page 10: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Mnm = -W

W exp{ i(m-n) t } d

0

W cos( (m-n) t ) d

2 sin{ (m-n) t W } / { (m-n) t}

2W sin{ (m-n) t W } / { W (m-n) t}

= 2W sinc{ (m-n) t W }

Note M is a symmetric matrix …

We can do the integral analytically …

Page 11: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Does anyone remember how to do a constrained maximization ?

Maximize:

R = n m Tn Tm Mnm

with constraint C = n Tn2

– 1= 0

Page 12: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Method of Lagrange Multipliers

Maximize R with constraint C=0

equivalent to

Maximize =R-C with no constraint

is new unknown, the Lagrange multiplier

Page 13: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Minimize = n m Tn Tm Mnm - n Tn2

+

With respect to Tq

d/dTq = 0 = n m dTn/dTq Tm Mnm

+ n m Tn dTm/dTq Mnm - 2 n Tn dTn/dTq =

n m nq Tm Mnm + m Tn mq Mnm - 2 n Tn nq =

m Tm Mqm - 2 Tq

Page 14: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Minimize = n m Tn Tm Mnm - n Tn2

– 1)

with respect to Tq

Yields this equation for Tq:

m Mqm Tm - Tq

Does anyone recognize it?

Page 15: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

M T = T

The algebraic eigenvalue problem

With symmetric NN matrix, M

has N solutions, say T(n)

each with a different eigenvalue , say (n)

a distinct pair of solutions are mutually orthogonal if their eigenvalues are different

Page 16: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Interpretation of eigenvalues

Start with M T = T and premultiply by TT

TTM T = TTT and rearrange

TTM T / TTT = R = amount of power near =0

The value of the quantity that we sought to maximize.

Page 17: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Tapering strategyPick a W

Find N tapers by solving the eigenvalue problem MT=T

Sort the tapers, smallest eigenvalue first

Choose the last few*, they have the best R values

Compute spectra of time-series times each of these tapers

Average the results

WW

It turns out that the number of dominant eigenvalues is about NW/ny, which is called the Shannon number.

Page 18: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Example based on 128-point time-series

W/ny = 1/(N/2);

tapers computed by MatLab[V,D] = eig( M )

function

(in practice you would not do this, but rather use a custom multi-taper code that computes the tapers for you in a more efficient way)

Page 19: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Eigenvalues, smallest to biggest

’s...0.00350.04300.27460.72180.95940.99760.9999

use

Page 20: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Tapers, Ti

time, t

Similar to Hanning Taper

T1

T2

T3

T4

T5

T6

Gives more emphasis to ends of time-series

Page 21: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

time-series, x

time, t

cosine

T1 x

T2 x

T3 x

T4 x

T5 x

T6 x

Page 22: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

frequency,

spectrum of T1

spectrum of T2

spectrum of T3

spectrum of T4

spectrum of T5

spectrum of T6

Page 23: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

frequency,

spectrum of T1 x

spectrum of T2 x

spectrum of T3 x

spectrum of T4 x

spectrum of T5 x

spectrum of T6 x

sum of first 4

spectrum of x

Results

Page 24: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Autocorrelation

A() = -+

T(t) T(t-) dt called the lag

T(t)

t

T(t)

t

Offset by , multiply and add to get A()

Page 25: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Autocorrelation

A() = -+

T(t) T(t-) dt called the lag

A()

A() = -+

T(t)2 dt = power in time-series

A()=A(-) symmetrical function

A() = T() * T(-)

Signal convolved with backwards-in-time signal

Page 26: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Example

T(t) A()

t

Page 27: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Another Example

T(t) A()

t

Decay of tales due to finite length of time-series

2-point running average of random number sequence

Page 28: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

MatLab Code

t=dt*[0:N-1]';

x = whatever

y=xcorr(x);

tau=dt*[1-N:N-1]';

Page 29: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Fourier Autocorrelation Theorem

FT of Autocorrelation is spectrum of T(t)

A() = |T()|2

Page 30: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

A() = -+

-+

T(t) T(t-) dt exp(-) d

-+

T(t) -+

T(t-) exp(-) ddt

= - -+

T(t) +-

T(t’) exp{-(t-t’)} dt’dt

= -+

T(t) exp(-t) dt -+

T(t’) exp(+t’) dt’

= T() T()* = |T()|2

t’= t- so =t-t’ and dt’=-dand t’-

Page 31: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Stationary time-serieshas a well-defined autocorrelation to

arbitrarily large lag

length-N section cut from time-series autocorrelation non-zero only to lag N

and furthermoremore you lag it, the more you

‘lose the ends’

Page 32: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

[T0 T1 T2 T3 T4 T5 T6 T7 T8 ]=0

[T0 T1 T2 T3 T4 T5 T6 T7 T8 ]multiply and add 9 terms

[T0 T1 T2 T3 T4 T5 T6 T7 T8 ]=4

[T0 T1 T2 T3 T4 T5 T6 T7 T8 ]

multiply and add only 5 terms …not as good an approximation …

Page 33: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

So another way of understanding the problem of estimating the spectrum of

a stationary time series is

Autocorrelation is poorly estimated at large lags …

Page 34: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Crosscorrelation

Auto-correlation

A() = -+

T(t) T(t-) dt

Cross-correlation

X() = -+

T1(t) T2(t-) dt

Generalization of the autocorrelation to two different time-series. In MatLab xcorr(x) is the autocorrelation and xcorr(x1,x2) is the crosscorrelation

Page 35: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Filter design and autocorrelation

Page 36: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

y0

y1

y2

…yN

f0

f1

…fN

x0 0 0 0 0 0x1 x0 0 0 0 0x2 x1 x0 0 0 0 …xN … x3 x2 x1 x0

=

In matrix form this is the equation y = G fthe least-squares estimate of y involves the two

matrices GTG and GTy

Recall this formulation of the convolution equationy = f * x

Page 37: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

y0

y1

y2

…yN

f0

f1

…fN

x0 0 0 0 0 0x1 x0 0 0 0 0x2 x1 x0 0 0 0 …xN … x3 x2 x1 x0

=

but GTG are just the columns of G dotted with each otherand GTy is just the columns of G dotted with y

[GTy]1 [GTG]3,5

By inspection: [GTG]i,j autocorrelation of x at lag i-jand [GTy]i crosscorrelation of x and y at lag i

Page 38: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

X(0)X(1)X(2)…X(N)

f0

f1

…fN

A(0) A(1) A(2) …A(1) A(0) A(1) … A(2) A(1) A(0) ……A(N) A(N-1) A(N-2) …

=

[GTG] f = GTy

So least-squares filter design relies very heavilty on knowledge of the autocorrelation function of a time-series

To find a filter of length N, you need to know the first N-1 lags of the autocorrelation function

Page 39: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Now back to spectral analysis

Suppose that we want to compute the spectrum of a stationary time-series x(t)

We think we know the only the first N-1 autocorrelation coefficients well

Strategy: compute a filter of length N that tells you something about the spectrum of x(t)

Page 40: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

The Autoregressive (AR) Spectral Method

Assume that a stationary time-series x(t) is created by a filter, S(t) acting on uncorrelated random noise n(t)

x(t) = S(t) * n(t)

Now in the Fourier domain, x()=S() n() and

|x()|2 = |S()|2 |n()|2

Page 41: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

|x()|2 = |S()|2 |n()|2

But noise has a ‘white spectrum, that is ‘fluctuating but on-average constant’

So |x()|2 |S()|2

The AR method chooses S(t) so that Sinv(t) is a short filter, f.

Page 42: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

x(t) = S(t) * n(t) = finv(t) * n(t)

or

x(t) * f(t) = n(t)

The least-squares equations are

j Aij fj = Xi = 0

With Aij the autocorrelation of x at lag (i-j) andWith Xi the crosscorrelation of x and n at lag i

But the cross-correlation of anything with random noise is zero

Page 43: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

In order to be able to solve this equation, you need to impose some constraint on f, say f0=1.

So the least-squares equation is:

j Aij fj = 0 with constraint f0=1

One you get f, then the spectrum of x(t) is computed as

|x()|2= |f()|-2

Page 44: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Example LGA Temperature Timeseries

LGA time-series

Hanning Taper

Tapered time-series

Page 45: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

AR spectrum, filter-length = 256

Standard Spectrum

Page 46: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Phase spectra

If we write the Fourier Transform

C() = |C()| exp{ -i () }

The quantity () is called the phase spectrum

() = -tan-1( Cimag / Creal )

Page 47: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

shifting a spike

We’ve seen something like this before …

If we have a time-series p(t), and want to shift it in time by t0, then we multiply its FT by exp(-t0)

Page 48: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

p(t)

ifft(exp(-it0)fft(p(t))) with t0=50

t

t

Page 49: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

shifting a spike

Suppose we take p(t) to be spike at the origin

The FT of a spike at the origin is just unity |C()|=1

So the FT of a shifted spike is exp(-t0)

So a shifted spike as a phase spectrum of ()=t0

… this is called a phase ramp

Page 50: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

But suppose we wanted to shift each frequency by a different amount?

We might imagine that at position x=0, the time-series is a spike, but that at a position

x>0 each frequency has shifted by t0()=x/v0() where v() is a frequency-

dependent velocity

Page 51: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Example

v()

()

()

x=100

x=200

v()=1+exp(-||/c) with c=2ny

Page 52: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Time-series

p(t,x=0)

x=100

x=100

p(t,x=100)

p(t,x=200)

dispersed wave train

Page 53: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Attempt to recover phase spectrum from timeseries

=x/v with x=100

Phase wrapping problem

=atan2(imag(r),imag(r))

with r=fft(p100)./fft(p0)

Page 54: Lecture 18 advanced topics is spectral analysis Parsival’s Theorem Multi-taper spectral analysis Auto- and Cross- Correlation Phase spectra

Recovering phase spectrum is tricky

Problem is that arc tangent cycles between – and +

Whereas phase () and increase out of the – to + range

Even the best phase unwrapping algorithms are unreliable