View
221
Download
1
Embed Size (px)
Citation preview
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
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
Multi-taper spectral analysis
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
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
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
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
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
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 …
Does anyone remember how to do a constrained maximization ?
Maximize:
R = n m Tn Tm Mnm
with constraint C = n Tn2
– 1= 0
Method of Lagrange Multipliers
Maximize R with constraint C=0
equivalent to
Maximize =R-C with no constraint
is new unknown, the Lagrange multiplier
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
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?
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
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.
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.
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)
Eigenvalues, smallest to biggest
’s...0.00350.04300.27460.72180.95940.99760.9999
use
Tapers, Ti
time, t
Similar to Hanning Taper
T1
T2
T3
T4
T5
T6
Gives more emphasis to ends of time-series
time-series, x
time, t
cosine
T1 x
T2 x
T3 x
T4 x
T5 x
T6 x
frequency,
spectrum of T1
spectrum of T2
spectrum of T3
spectrum of T4
spectrum of T5
spectrum of T6
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
Autocorrelation
A() = -+
T(t) T(t-) dt called the lag
T(t)
t
T(t)
t
Offset by , multiply and add to get A()
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
Example
T(t) A()
t
Another Example
T(t) A()
t
Decay of tales due to finite length of time-series
2-point running average of random number sequence
MatLab Code
t=dt*[0:N-1]';
x = whatever
y=xcorr(x);
tau=dt*[1-N:N-1]';
Fourier Autocorrelation Theorem
FT of Autocorrelation is spectrum of T(t)
A() = |T()|2
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’-
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’
[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 …
So another way of understanding the problem of estimating the spectrum of
a stationary time series is
Autocorrelation is poorly estimated at large lags …
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
Filter design and autocorrelation
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
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
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
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)
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
|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.
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
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
Example LGA Temperature Timeseries
LGA time-series
Hanning Taper
Tapered time-series
AR spectrum, filter-length = 256
Standard Spectrum
Phase spectra
If we write the Fourier Transform
C() = |C()| exp{ -i () }
The quantity () is called the phase spectrum
() = -tan-1( Cimag / Creal )
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)
p(t)
ifft(exp(-it0)fft(p(t))) with t0=50
t
t
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
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
Example
v()
()
()
x=100
x=200
v()=1+exp(-||/c) with c=2ny
Time-series
p(t,x=0)
x=100
x=100
p(t,x=100)
p(t,x=200)
dispersed wave train
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)
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