Sie sind auf Seite 1von 66

Spectral Analysis and Time Series

Andreas Lagg

Part I: fundamentals  Part II: Fourier series Part III: Wavelets


on time series

classification definition why wavelet 


prob. density func. method transforms?
auto­correlation properties fundamentals:
FT, STFT and 
power spectral density convolution
resolution problems
cross­correlation correlations
multiresolution 
applications leakage / windowing analysis: CWT
pre­processing irregular grid DWT
sampling noise removal
trend removal
Exercises

A. Lagg – Spectral Analysis
Basic description of physical data

deterministic: described by explicit mathematical relation

x t =X cos
 k
t
t

n
non deterministic: no way to predict an exact value at a future instant of time
o
n
 
d
e
t
e
r
m A. Lagg – Spectral Analysis
Classifications of deterministic data

Deterministic

Periodic Nonperiodic

Sinusoidal Complex Periodic Almost periodic Transient

A. Lagg – Spectral Analysis
Sinusoidal data

x t =X sin 2  f 0 t


T =1/ f 0

time history frequency spectrogram

A. Lagg – Spectral Analysis
Complex periodic data

x t =x t±nT  n=1,2,3,...


a0
x t  =
2
 ∑ an cos 2  n f 1 t  b n sin 2  n f 1 t 
(T = fundamental period)
time history frequency spectrogram

A. Lagg – Spectral Analysis
Almost periodic data

x t =X 1 sin 2 t1   X 2 sin 3 t2   X 3 sin   50 t3 

no highest common divisor  ­>  infinitely long period T

time history frequency spectrogram

A. Lagg – Spectral Analysis
Transient non­periodic data
all non­periodic data other than almost periodic data

{
−at
Ae t≥0
x t =
0 t0

{
−at
Ae cos bt t≥0
x t =
0 t0

x t =
{ A
0
c≥t≥0
ct0

A. Lagg – Spectral Analysis
Classification of random data

Random Data

Stationary Nonstationary

Ergodic Nonergodic Special classifications


 of nonstationarity

A. Lagg – Spectral Analysis
stationary / non stationary

collection of sample functions = ensemble

data can be (hypothetically) described by 
computing ensemble averages (averaging over 
multiple measurements / sample functions)

mean value (first moment):
N
1
 x t 1 = lim ∑ x k t 1 
N  ∞ N k=1

autocorrelation function (joint moment):
N
1
R x t 1, t 1= lim ∑ x k t 1  x k t 1
N  ∞ N k=1

stationary:   x t 1 = x , R x t 1, t 1=R x


weakly stationary:   x t 1 = x , R x t 1, t 1=R x 

A. Lagg – Spectral Analysis
ergodic / non ergodic
Ergodic random process:
properties of a stationary random process 
described by computing averages over only one 
single sample function in the ensemble

mean value of k­th sample function:
T
1
 x k =lim
T ∞

T 0
x k t  dt

autocorrelation function (joint moment):
T
1
R x  , k =lim ∫ x k t  x k t dt
T ∞ T 0

ergodic:   x k = x , R x  , k =R x 

A. Lagg – Spectral Analysis
Basic descriptive properties of random data

mean square values
propability density function
autocorrelation functions
power spectral density functions

(from now on: assume random data to be stationary and ergodic)

A. Lagg – Spectral Analysis
Mean square values (mean values and variances)

T
1
describes general intensity of random data:  2x = lim ∫ x 2 t  dt
T ∞ T 0

rout mean square value:   x
rms
=  2
x

often convenient: T
1
static component described by mean value:  x = lim
T ∞ T
∫ x t  dt
0

T
1
dynamic component described by variance:  2x = lim
T ∞ T
∫ [ x t − 2
x dt
]
0

=  2x − 2
standard deviation:   x =  2
x
x

A. Lagg – Spectral Analysis
Probability density functions

describes the probability that the data will assume a value within some defined 
range at any instant of time k
Tx
Prob[ xx t ≤x x ] = lim , T x =∑  t i
T ∞ T i=1
 x Prob[ xx t ≤x x ] ≈ p x x
for small         :
probability density function
p x = lim
x0
Prob[ xx t ≤x x ]
x
= lim
1
lim
Tx
 x 0  x T ∞ T
[ ]
probability distribution function
P  x = Prob[x t≤x]
x

= ∫ p d 
−∞

A. Lagg – Spectral Analysis
Illustration: probability density function

sample time histories:
sine wave (a)
sine wave + random noise
narrow­band random noise
wide­band random noise

all 4 cases: mean value  x =0

A. Lagg – Spectral Analysis
Illustration: probability density function
probability density function

A. Lagg – Spectral Analysis
Autocorrelation functions

describes the general dependence of the data values at one time on the 
values at another time.
T
1
R x  = lim ∫ x t  x t dt
T ∞ T 0

x =  R x ∞ 2
 x = R x 0 (not for special cases like sine waves)

A. Lagg – Spectral Analysis
Illustration: ACF
autocorrelation functions (autocorrelogram)

A. Lagg – Spectral Analysis
Illustrations
autocorrelation function of a rectangular pulse

x t  x t−

autocorrelation function

A. Lagg – Spectral Analysis
Power spectral density functions
(also called autospectral density functions)

describe the general frequency composition of the data in terms 
of the spectral density of its mean square value

mean square value in frequency range                          :
 f , f  f 
T
1
 2x  f ,  f  = lim
T ∞

T 0 
x t , f ,  f 
2
dt
portion of x(t) in (f,f+∆f)
2
definition of power spectral density function:  x  f ,  f  ≈ G x  f  f
 2x  f ,  f 
[ ]
T
1 1
G x  f  = lim = lim lim ∫ x t , f ,  f 2 dt
 f 0 f  f 0  f T ∞ T 0

important property: spectral density function is related to the 
autocorrelation function by a Fourier transform:
∞ ∞
G x  f  = 2 ∫ R x e d  = 4 ∫ R x  cos 2  f  d 
−i 2  f 

−∞ 0

A. Lagg – Spectral Analysis
Illustration: PSD
power spectral density functions

Dirac delta function at f=f0 sine wave

sine wave
+ random noise

narrowband
noise

“white” noise:
spectrum is uniform over  broadband
all frequencies noise

A. Lagg – Spectral Analysis
Joint properties of random data

until now: described properties of an 
individual random process 

Joint probability density functions
joint properties in the amplitude domain

Cross­correlation functions
joint properties in the time domain
joint probability measurement
Cross­spectral density functions
joint properties in the frequency domain

A. Lagg – Spectral Analysis
Cross­correlation function

describes the general dependence of 
one data set to another
T
1
R xy  = lim ∫ x t  y t dt
T ∞ T 0

similar to autocorrelation function
R xy =0 functions are 
uncorrelated

cross­correlation measurement

typical cross­correlation plot (cross­correlogram):
sharp peaks indicate the existence of a correlation 
between x(t) and y(t) for specific time displacements

A. Lagg – Spectral Analysis
Applications

Measurement of time delays
2 signals:
different offset
different S/N
time delay 4s

often used:
'discrete' cross correlation coefficient
lag =l, for l >=0:
N −l

∑  x k − x  y kl −y 
k=1
R xy l =


N N

∑  x k − x 2
∑  y k −y 2

k=1 k=1

A. Lagg – Spectral Analysis
Applications
Detection and recovery from 
signals in noise

3 signals:
noise free replica of the signal 
(e.g. model)
2 noisy signals

cross correlation can be used to 
determine if theoretical signal is 
present in data

A. Lagg – Spectral Analysis
Pre­processing Operations
sampling considerations
trend removal
filtering methods

sampling
cutoff frequency (=Nyquist 
frequency or folding frequency)

1
fc =
2h

A. Lagg – Spectral Analysis
Trend removal

often desirable before performing a 
spectral analysis

Least­square method:

time series:  ut 
K
desired fit
   (e.g. polynomial): 

u = bk nh
k
n=1,2,... , N
k=0
N

Lsq­Fit: minimize  Qb=∑ u n −u n 


2

n=1
N
 set partial ∂Q
=
derivatives to 0:  ∂ b n=1 ∑
2u n − u
 n [−nh
l
]
l
K N N

 K+1 equations: ∑ bk ∑ nhkl = ∑ un nhl


k=0 n=1 n=1

A. Lagg – Spectral Analysis
Digital filtering

A. Lagg – Spectral Analysis
end of part I ...

A. Lagg – Spectral Analysis
Spectral Analysis and Time Series
Andreas Lagg

Part I: fundamentals  Part II: Fourier series Part III: Wavelets


on time series

classification definition why wavelet 


prob. density func. method transforms?
auto­correlation properties fundamentals:
FT, STFT and 
power spectral density convolution
resolution problems
cross­correlation correlations
multiresolution 
applications leakage / windowing analysis: CWT
pre­processing irregular grid DWT
sampling noise removal
trend removal
Exercises

A. Lagg – Spectral Analysis
Fourier Series and Fast Fourier Transforms

Standard Fourier series procedure:
if a transformed sample record x(t) is periodic with a period Tp (fundamental 
frequency f1=1/Tp), then x(t) can be represented by the Fourier series:

a0 ∞
x t  = ∑ a q cos 2  q f 1 t  bq sin 2  q f 1 t 
2 q=1
T
2
where aq =
T
∫ x t  cos 2  q f 1 t dt q=0,1,2,. ..
0
T
2
bq =
T
∫ x t sin 2  q f 1 t dt q=1,2,3,...
0

A. Lagg – Spectral Analysis
Fourier series procedure ­ method

sample record of finite length, equally spaced sampled:

x n = x nh n=1,2,. .. , N

Fourier series passing through these N data values:

   
N /2 N /2−1
2qt 2qt
x t  = A0  ∑ Aq cos  ∑ Bq sin
q=1 Tp q=1 Tp
Fill in particular points: t=nh , n=1,2,... , N , T p =Nh , x n =x nh = ...
N N
1 1
  coefficients Aq and Bq: A0 = ∑
N n=1
x n = x A N /2 = ∑
N n=1
x n cos n 
N
2 2qn N
Aq = ∑
N n=1
x n cos
N
q=1,2,... ,
2
−1
N
2 2qn N
Bq = ∑
N n=1
x n sin
N
q=1,2,... ,
2
−1

inefficient & slow => Fast Fourier Trafos developed

A. Lagg – Spectral Analysis
Fourier Transforms ­ Properties

Linearity DFT
{x n } ⇔ {X k }
DFT
{y n } ⇔ {Y k }
DFT
a {x n }b {y n } ⇔ a {X k }b {Y k }

Symmetry {X k } = ∗
{X −k }
ℜ {X k } is even ℑ {X k } is odd

Circular time shift DFT
−i k n 0
{x n−n } 0
⇔ {e Xk}
DFT
i k0 n
{e yn } ⇔ {Y k−k } 0

A. Lagg – Spectral Analysis
Using FFT for Convolution


r*s ≡ ∫
−∞
r  st− d 
original data
Convolution Theorem:
FT
r * s ⇔ R f  S  f 
response function
Fourier transform of the convolution 
is product of the individual Fourier 
transforms
convolved data
discrete case:
N /2
(note how the response function for negative times is wrapped 
r * s j ≡ ∑ s j−k r k around and stored at the extreme right end of the array)
k=−N /21

Convolution Theorem: constraints:
N /2
FT duration of r and s are not the same
∑ s j−k r k ⇔ R n S n
signal is not periodic
k=−N /21

A. Lagg – Spectral Analysis
Treatment of end effects by zero padding

constraint 1: simply expand response function to length N by padding it with zeros
constraint 2: extend data at one end with a number of zeros equal to the max. 
positive / negative duration of r (whichever is larger)

A. Lagg – Spectral Analysis
FFT for Convolution

1. zero­pad data
2. zero­pad response function
(­> data and response function have N elements)
3. calculate FFT of data and response function
4. multiply FFT of data with FFT of response function
5. calculate inverse FFT for this product

Deconvolution
­> undo smearing caused by a response function
use steps (1­3), and then:
4. divide FFT of convolved data with FFT of response 
function
5. calculate inverse FFT for this product

A. Lagg – Spectral Analysis
Correlation / Autocorrelation with FFT

definition of correlation / autocorrelation see first lecture

Corr g , h = g * h = ∫
−∞
gt h d 

Correlation Theorem:
FT *
Corr g , h ⇔ G  f  H  f 
Auto­Correlation:
FT 2
Corr g , g ⇔ ∣G  f ∣

discrete correlation theorem:
N −1
Corr g , h j ≡ ∑ g jk hk
k=0
FT
⇔ G k H *k

A. Lagg – Spectral Analysis
Fourier Transform ­ problems

spectral leakage

T =n T p T ≠n T p

A. Lagg – Spectral Analysis
reducing leakage by windowing (1)

Applying windowing (apodizing) function to data record:
x t  = x t  wt  (original data record  x  windowing function)
x n = x n w n

No Window: Bartlett Window: Hamming Window:

∣t−T /2∣
wt =1− wt =0.540.46∗cos t 
T /2

Blackman Window: Hann Window: Gaussian Window:

wt  = 0.420.5∗cos t  t
wt =cos2  
0.08 cos2  t  2 wt =exp −0.5a t 2 

A. Lagg – Spectral Analysis
reducing leakage by windowing (2)

without windowing with Gaussian windowing

A. Lagg – Spectral Analysis
No constant sampling frequency

Fourier transformation requires constant sampling (data points at 
equal distances)
­> not the case for most physical data

Solution: Interpolation
linear:
inear interpolation between yk and yk+1
IDL> idata=interpol(data,t,t_reg)
quadratic: important:
quadratic interpolation using yk­1, yk and yk+1
IDL> idata=interpol(data,t,t_reg,/quadratic) interpolation changes 
sampling rate!
least­square quadratic
least­square quadratic fit using yk­1, yk, yk+1 and yk+2
­> careful choice of 
IDL> idata=interpol(data,t,t_reg,/lsq) new (regular) time grid 
spline necessary!
IDL> idata=interpol(data,t,t_reg,/spline)
IDL> idata=spline(t,data,t_reg[,tension])

A. Lagg – Spectral Analysis
Fourier Transorm on irregular gridded data ­ Interpolation

original data: sine wave + noise
FT of original data
irregular sampling of data (measurement)
interpolation: linear, lsq, spline, quadratic
're­sampling' 
FT of interpolated data

A. Lagg – Spectral Analysis
Noise removal
Frequency threshold (lowpass)
make FT of data
set high frequencies to 0
transorm back to time 
domain

A. Lagg – Spectral Analysis
Noise removal
signal threshold for
weak frequencies (dB­threshold)
make FT of data
set frequencies with amplitudes 
below a given threshold to 0
transorm back to time domain

A. Lagg – Spectral Analysis
Optimal Filtering with FFT

normal situation with measured data: ∞

underlying, uncorrupted signal u(t) st  = ∫
−∞
r t−u d 
  + response function of measurement r(t) c t  = st nt 
  = smeared signal s(t)
  + noise n(t)
  = smeared, noisy signal c(t)

estimate true signal u(t) with:
C  f  f 
U  f  =
R f 
 f  , t  = optimal filter
(Wiener filter)

A. Lagg – Spectral Analysis
Calculation of optimal filter

reconstructed signal and uncorrupted signal should be close in least­square sense:
­> minimize  ∞ ∞

∫ ∣u t −ut ∣ dt =
−∞
2
∫ ∣U  f −U  f ∣ df
−∞
2

∣ ∣ =0
2
∂ [S  f N  f ] f  S  f 
⇒ −
∂  f  R f  R f 
2
∣S  f ∣
⇒  f  = 2 2
∣S  f ∣ ∣N  f ∣

additional information:
power spectral density can often 
be used to disentangle noise 
function N(f) from smeared 
signal S(f)

A. Lagg – Spectral Analysis
Using FFT for Power Spectrum Estimation

discrete Fourier transform of c(t)
­> Fourier coefficients: N −1
C k= ∑ c j e
2i j k / N
k=0,... , N −1
j=0

­> periodogram estimate of 
power spectrum:
Periodogram
1 2
2 ∣ 0∣
P 0 = P  f 0 = C
N
1
P f k =
N
[
2 ∣ k∣
C
2
∣ N −k∣
C
2
]
1 2
P  f c = P  f N / 2 = 2 ∣C N / 2∣
N

A. Lagg – Spectral Analysis
end of FT

A. Lagg – Spectral Analysis
Spectral Analysis and Time Series
Andreas Lagg

Part I: fundamentals  Part II: Fourier series Part III: Wavelets


on time series

classification definition why wavelet 


prob. density func. method transforms?
auto­correlation properties fundamentals:
FT, STFT and 
power spectral density convolution
resolution problems
cross­correlation correlations
multiresolution 
applications leakage / windowing analysis: CWT
pre­processing irregular grid DWT
sampling noise removal
trend removal
Exercises

A. Lagg – Spectral Analysis
Introduction to Wavelets

why wavelet transforms?
fundamentals: FT, short term FT and resolution 
problems
multiresolution analysis:
continous wavelet transform
multiresolution analysis:
discrete wavelet transform

A. Lagg – Spectral Analysis
Fourier: lost time information
6 Hz, 4 Hz,  2 Hz,          1 Hz 6 Hz + 4 Hz + 2 Hz + 1 Hz

A. Lagg – Spectral Analysis
Solution: Short Time Fourier Transform
(STFT)

perform FT on 'windowed' function:
example: rectangular window
move window in small steps over data
perform FT for every time step

STFT  f , t '  = ∫ [ x t t−t ' ]e −i 2  f t


dt
t

A. Lagg – Spectral Analysis
Short Time Fourier Transform

STFT

STFT­spectrogram shows both time and 
frequency information!

A. Lagg – Spectral Analysis
Short Time Fourier Transform: Problem
narrow window function ­> good time resolution
wide window function ­> good frequency resolution

Gauss­functions as 
windows

A. Lagg – Spectral Analysis
Solution: Wavelet Transformation

time vs. frequency resolution is intrinsic problem (Heisenberg Uncertainty Principle)
approach: analyze the signal at different frequencies with different resolutions

­> multiresolution analysis (MRA)

Continuous Wavelet Transform

similar to STFT: but:
signal is multiplied with a  the FT of the windowed signals are 
function (the wavelet) not taken
transform is calculated  (no negative frequencies)
separately for different segments  The width of the window is changed 
of the time domain as the transform is computed for 
every single spectral component

A. Lagg – Spectral Analysis
Continuous Wavelet Transform

CWT 
x

=  , s =
x
1

∣s∣ t
x t  
* t−

s
dt

 ... translation parameter , s ... scale parameter


t  ... mother wavelet  = small wave
mother wavelet:
finite length (compactly 
supported) ­>'let'
oscillatory ­>'wave'
scale parameter s replaces frequency in STFT
functions for different 
regions are derived from 
this function ­> 'mother'

A. Lagg – Spectral Analysis
The Scale

similar to scales used in maps:
high scale = non detailed global view (of the signal)
low scale = detailed view

in practical applications:
low scales (= high frequencies) 
appear usually as short bursts or 
spikes
high scales (= low frequencies) last 
for entire signal

scaling dilates (stretches out) or 
compresses a signal:
s > 1 ­> dilation
s < 1 ­> compression

A. Lagg – Spectral Analysis
Computation of the CWT

signal to be analyzed: x(t), mother wavelet: Morlet or Mexican Hat

start with scale s=1 (lowest scale, 
highest frequency)
­> most compressed wavelet
shift wavelet in time from t0 to t1
increase s by small value
shift dilated wavelet from t0 to t1
repeat steps for all scales 

A. Lagg – Spectral Analysis
CWT ­ Example

signal x(t)
axes of CWT: translation and 
scale (not time and frequency)
translation ­> time
scale ­> 1/frequency

A. Lagg – Spectral Analysis
Time and Frequency Resolution

every box corresponds to a value of the wavelet 
transform in the time frequency plane

all boxes have constant area
 Δf Δt = const.
low frequencies: high resolution 
in f, low time resolution
high frequencies: good time 
resolution

STFT: time and frequency 
resolution is constant (all boxes 
are the same)

A. Lagg – Spectral Analysis
Wavelets: Mathematical Approach

 
WL­transform: 1 * t−
CWT x =x  , s = ∫ x t  dt
∣s∣ t s

Mexican Hat wavelet: Morlet wavelet:

 
2
−t 2 t2
1 t −
t  = e 2 2
−1 t  = ei a t e 2

s 3
 2

 
inverse WL­transform: 1 1 t−
x t  = 2 ∫∫  x  , s 2 

d  ds
c s  s s
admissibility  ∣
 ∞

2 1/ 2 FT
condition: c={2  ∫ d } ∞ with 
 ⇔ t 
−∞ ∣∣
A. Lagg – Spectral Analysis
Discretization of CWT: Wavelet Series

­> sampling the time – frequency (or scale) plane
advantage:
sampling high for high frequencies (low scales) s1
N2 = N1
scale s1 and rate N1 s2
sampling rate can be decreased for low  f2
frequencies (high scales) N2 = N1
f1
scale s2 and rate N2

continuous wavelet discrete wavelet
1
 , s = 
s  
t−
s
  j , k t  = s−0 j /2 s−0 j t−k 0  ,  j , k orthonormal

x j , k = ∫ x t *j , k t  dt WL­transformation


t
reconstruction of 
x t  = c ∑ ∑ x j , k  j , k t 
j k
signal

A. Lagg – Spectral Analysis
Discrete Wavelet Transform
(DWT)

discretized continuous wavelet transform is only a sampled version of the CWT
The discrete wavelet transform (DWT) has significant advantages for 
implementation in computers.

excellent tutorial:
http://users.rowan.edu/~polikar/WAVELETS/WTtutorial.html

IDL­Wavelet Tools:
IDL> wv_applet

Wavelet expert at MPS:
Rajat Thomas

A. Lagg – Spectral Analysis
end of Wavelets

A. Lagg – Spectral Analysis
Exercises

Part I: Fourier Analysis
(Andreas Lagg)

Instructions:
http://www.linmpi.mpg.de/~lagg

Part II: Wavelets
(Rajat Thomas)

Seminar room
Time: 15:00

A. Lagg – Spectral Analysis
Exercise: Galileo magnetic field

data set from Galileo magnetometer  Tips:
(synthesized) restore,'gll_data.sav'
file: gll_data.sav, contains: use IDL­FFT
total magnetic field remember basic plasma 
radial distance physics formula for the 
time in seconds ion cyclotron wave:
qB gyro
gyro= , f gyro=
m 2
your tasks: Background:
If the density of ions is high enough they will excite ion cyclotron waves 
Which ions are present? during gyration around the magnetic field lines. This gyration frequency 
only depends on mass per charge and on the magnitude of the magnetic 
Is the time resolution of 
field.
the magnetometer 
In a low­beta plasma the magnetic field dominates over plasma effects. 
sufficient to detect  The magnetic field shows only very little influence from the plasma and 
electrons or protons? can be considered as a magnetic dipole.
http://www.sciencemag.org/cgi/content/full/274/5286/396

A. Lagg – Spectral Analysis
Literature

Random Data: Analysis and Measurement Procedures
Bendat and Piersol, Wiley Interscience, 1971

The Analysis of Time Series: An Introduction
Chris Chatfield, Chapman and Hall / CRC, 2004

Time Series Analysis and Its Applications
Shumway and Stoffer, Springer, 2000

Numerical Recipies in C
Cambridge University Press, 1988­1992
http://www.nr.com/

The Wavelet Tutorial
Robi Polikar, 2001
http://users.rowan.edu/~polikar/WAVELETS/WTtutorial.html

A. Lagg – Spectral Analysis

Das könnte Ihnen auch gefallen