DSP
DSP
DSP
c Danilo P. Mandic
Digital Signal Processing 1
Motivation:- Wold Decomposition Theorem
The most fundamental justification for time series analysis is due to Wold’s
decomposition theorem, where it is explicitly proved that any (stationary)
time series can be decomposed into two different parts.
Therefore, a general random process can be written a sum of two processes
E{xr [m]xp[n]} = 0
c Danilo P. Mandic
Digital Signal Processing 2
What do we actually mean?
c Danilo P. Mandic
Digital Signal Processing 3
Example from brain science
c Danilo P. Mandic
Digital Signal Processing 4
Linear Stochastic Processes
It therefore follows that the general form for the power spectrum of a WSS
process is
N
X
Px(eω ) = Pxr (eω ) + αk u0(ω − ωk )
k=1
c Danilo P. Mandic
Digital Signal Processing 5
ACF and Spectrum of ARMA models
Much of interest are the autocorrelation function and power spectrum of
these processes. (Recall that ACF ≡ P SD in terms of the available
information)
Suppose that we filter white noise w[n] with a causal linear shift–invariant
filter having a rational system function with p poles and q zeros
Pq
Bq (z) k=0 bq (k)z −k
H(z) = = Pp
Ap(z) 1 + k=1 ap(k)z −k
Assuming that the filter is stable, the output process x[n] will be
2
wide–sense stationary and with Pw = σw , the power spectrum of x[n] will
be
−1
2 Bq (z)Bq (z )
Px(z) = σw
Ap(z)Ap(z −1)
∗
Recall that “(·) ” in analogue frequency corresponds to “z −1” in “digital freq.”
c Danilo P. Mandic
Digital Signal Processing 6
Frequency Domain
In terms of “digital” frequency θ (unit circle – e−θ = e−ωT )
Bq (eθ )2
Pz (eθ ) = σw
2
2
|Ap(eθ )|
c Danilo P. Mandic
Digital Signal Processing 7
Example
Plot the power spectrum of an ARMA(2,2) process for which
• the zeros of H(z) are z = 0.95e±π/2
Solution: The system function is (poles and zeros – resonance & sink)
1 + 0.9025z −2
H(z) =
1 − 0.5562z −1 + 0.81z −2
7
Power Spectrum
−1
0 0.5 1 1.5 2 2.5 3 3.5
Frequency
c Danilo P. Mandic
Digital Signal Processing 8
Difference Equation Representation
Random processes x[n] and w[n] are related by the linear constant
coefficient equation
p
X q
X
x[n] − ap(l)x[n − l] = bq (l)w[n − l]
l=1 l=0
p
X q
X
rxx(k) − ap(l)rxx(k − l) = bq (l)rxw (k − l)
l=1 l=0
Since x is WSS, it follows that x[n] and w[n] are jointly WSS.
c Danilo P. Mandic
Digital Signal Processing 9
General Linear Processes: Stationarity and Invertibility
Consider a linear stochastic process # output from a linear filter, driven by
WGN w[n]
∞
X
x[n] = w[n] + b1w[n − 1] + b2w[n − 2] + · · · = w[n] + bj w[n − j]
j=1
The model implies that under suitable condition, x[n] is also a weighted
sum of past values of x, plus an added shock w[n], that is
c Danilo P. Mandic
Digital Signal Processing 10
Are these ARMA(p,q) processes?
0, n < 0
• Unit response u[n] =
1, n ≥ 0
– If w[n] = δ[n] then
c Danilo P. Mandic
Digital Signal Processing 11
Autoregressive Processes
Due to its “all–pole“ nature follows the duality between IIR and FIR filters.
c Danilo P. Mandic
Digital Signal Processing 12
ACF and Spectrum of AR Processes
To obtain the autocorrelation function of an AR process, multiply the
above equation by x[n − k] to obtain
c Danilo P. Mandic
Digital Signal Processing 13
Variance and Spectrum of AR Processes
Variance:
2
When k = 0 the contribution from the term E{x[n − k]w[n]} is σw , and
2
rxx(0) = a1rxx(−1) + a2rxx(−2) + · · · + aprxx(−p) + σw
Spectrum:
2
2σw
Pxx(f ) = 2 0 ≤ f ≤ 1/2
|1 − a1 e−2πf − · · · − ap e−2πpf |
c Danilo P. Mandic
Digital Signal Processing 14
Yule–Walker Equations
For k = 1, 2, . . . , p from the general autocorrelation function, we obtain
a set of equations:-
a = R−1
xx rxx
Due to Toeplitz structure of Rxx, its positive definitness enables matrix inversion
c Danilo P. Mandic
Digital Signal Processing 15
ACF Coefficients
ρk = rxx(k)/rxx(0)
we have
ρ1 = a1 + a2ρ1 + · · · + apρp−1
ρ2 = a1ρ1 + a2 + · · · + apρp−2
.. = ..
ρp = a1ρp−1 + a2ρp−2 + · · · + ap
c Danilo P. Mandic
Digital Signal Processing 16
Example:- Yule–Walker modelling in Matlab
In Matlab – Power spectral density using Y–W method pyulear
Pxx = pyulear(x,p)
[Pxx,w] = pyulear(x,p,nfft)
[Pxx,f] = pyulear(x,p,nfft,fs)
[Pxx,f] = pyulear(x,p,nfft,fs,’range’)
[Pxx,w] = pyulear(x,p,nfft,’range’)
Description:-
Pxx = pyulear(x,p)
c Danilo P. Mandic
Digital Signal Processing 17
Example:- AR(p) signal generation
• Generate the input signal x by filtering white noise through the AR
filter
Solution:-
randn(’state’,1);
x = filter(1,a,randn(256,1)); % AR system output
pyulear(x,4) % Fourth-order estimate
c Danilo P. Mandic
Digital Signal Processing 18
Alternatively:- Yule–Walker modelling
AR(4) system given by
y[n] = 2.2137y[n−1]−2.9403y[n−2]+2.1697y[n−3]−0.9606y[n−4]+w[n]
a = [1 -2.2137 2.9403 -2.1697 0.9606]; % AR filter coefficients
freqz(1,a) % AR filter frequency response
title(’AR System Frequency Response’)
c Danilo P. Mandic
Digital Signal Processing 19
From Data to AR(p) Model
So far, we assumed the model (AR, MA, or ARMA) and analysed the ACF
and PSD based on known model coefficients.
In practice:- DATA # MODEL
c Danilo P. Mandic
Digital Signal Processing 20
Example:- Finding parameters of
x[n] = 1.2x[n − 1] − 0.8x[n − 2] + w[n]
AR(2) signal x=filter([1],[1, −1.2, 0.8],w) ACF for AR(2) signal x=filter([1],[1, −1.2, 0.8],w) ACF for AR(2) signal x=filter([1],[1, −1.2, 0.8],w)
6 2000
1500
1500
4
1000
1000
2
500 500
0
0 0
−2
−500
−500
−4
−1000
−1000
−6 −1500
0 50 100 150 200 250 300 350 400 −400 −300 −200 −100 0 100 200 300 400 −20 −10 0 10 20
Sample number Correlation lag Correlation lag
c Danilo P. Mandic
Digital Signal Processing 21
Special case:- AR(1) Process (Markov)
Given below (Recall p(x[n], x[n − 1], . . . , x[0]) = p(x[n] | x[n − 1]))
ρk = ak1 , k>0
Notice the difference in the behaviour of the ACF for a1 positive and negative
c Danilo P. Mandic
Digital Signal Processing 22
Variance and Spectrum of AR(1) process
Can be calculated directly from a general expression of the variance and
spectrum of AR(p) processes.
2 2
σw σw
σx2 = =
1 − ρ1a1 1 − a21
2 2
2σw 2σw
Pxx(f ) = 2 = 1 + a2 − 2a cos(2πf )
|1 − a1e−2πf | 1
1
c Danilo P. Mandic
Digital Signal Processing 23
Example: ACF and Spectrum of AR(1) for a = ±0.8
x[n] = −0.8*x[n−1] + w[n] x[n] = 0.8*x[n−1] + w[n]
4 5
Signal values
Signal values
0 0
−2
−4 −5
0 20 40 60 80 100 0 20 40 60 80 100
Sample Number Sample Number
ACF ACF
1 1
0.5
Correlation
Correlation
0 0.5
−0.5
−1 0
0 5 10 15 20 0 5 10 15 20
Correlation lag Correlation lag
Power/frequency (dB/rad/sample)
Power/frequency (dB/rad/sample)
Burg Power Spectral Density Estimate Burg Power Spectral Density Estimate
10 15
5 10
5
0
0
−5
−5
−10 −10
−15 −15
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Normalized Frequency (×π rad/sample) Normalized Frequency (×π rad/sample)
c Danilo P. Mandic
Digital Signal Processing 24
Special Case:- Second Order Autoregressive Processes
AR(2)
a1 + a2 < 1
a2 − a1 < 1
−1 < a2 < 1
c Danilo P. Mandic
Digital Signal Processing 25
Work by Yule – Modelling of sunspot numbers
100
Signal values
50
−50
0 50 100 150 200 250 300
Sample Number
0.5
Correlation
−0.5
0 5 10 15 20 25 30 35 40 45 50
Correlation lag
c Danilo P. Mandic
Digital Signal Processing 26
Autocorrelation function of AR(2) processes
The ACF
ρk = a1ρk−1 + a2ρk−2 k>0
c Danilo P. Mandic
Digital Signal Processing 27
Stability Triangle
a2
1
ACF ACF
II I
m m
Real Roots
−2 2 a1
ACF
ACF
m
m
III Complex Roots IV
−1
c Danilo P. Mandic
Digital Signal Processing 28
Yule–Walker Equations
Substituting p = 2 into Y-W equations we have
ρ1 = a1 + a2ρ1
ρ2 = a1ρ1 + a2
a1
ρ1 =
1 − a2
a21
ρ2 = a2 +
1 − a2
c Danilo P. Mandic
Digital Signal Processing 29
Variance and Spectrum
Spectrum
2
2σw
Pxx(f ) = 2
|1 − a1e−2πf − a2e−4πf |
2
2σw
= , 0 ≤ f ≤ 1/2
1 + a21 + a22 − 2a1(1 − a2 cos(2πf ) − 2a2 cos(4πf ))
c Danilo P. Mandic
Digital Signal Processing 30
Example AR(2): x[n] = 0.75x[n − 1] − 0.5x[n − 2] + w[n]
10
Signal values
0
−10
−20
0 50 100 150 200 250 300 350 400 450 500
Sample Number
ACF
1
Correlation
0.5
−0.5
0 5 10 15 20 25 30 35 40 45 50
Correlation lag
Power/frequency (dB/rad/sample)
10
−5
−10
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
cos−1 (0.5303) 1
The damping factor D = 0.5 = 0.71, frequency f0 = 2π = 6.2
The fundamental period of the autocorrelation function is 6.2.
c Danilo P. Mandic
Digital Signal Processing 31
Partial Autocorrelation Function:- Motivation
Let us revisit example from page 21 of Lecture Slides.
AR(2) signal x=filter([1],[1, −1.2, 0.8],w) ACF for AR(2) signal x=filter([1],[1, −1.2, 0.8],w) ACF for AR(2) signal x=filter([1],[1, −1.2, 0.8],w)
6 2000
1500
1500
4
1000
1000
2
500 500
0
0 0
−2
−500
−500
−4
−1000
−1000
−6 −1500
0 50 100 150 200 250 300 350 400 −400 −300 −200 −100 0 100 200 300 400 −20 −10 0 10 20
Sample number Correlation lag Correlation lag
c Danilo P. Mandic
Digital Signal Processing 32
Partial Autocorrelation Function
c Danilo P. Mandic
Digital Signal Processing 33
Partial ACF Coefficients:
• For an AR(p) process, the PAC akk will be nonzero for k ≤ p and zero
for k > p ⇒ tells us the order of an AR(p) process.
c Danilo P. Mandic
Digital Signal Processing 34
Importance of Partial ACF
For a zero mean process x[n], the best linear predictor in the mean
square error sense of x[n] based on x[n − 1], x[n − 2], . . . is
x̂[n] = ak−1,1x[n − 1] + ak−1,2x[n − 2] + · · · + ak−1,k−1 x[n − k + 1]
(apply the E{·} operator to the general AR(p) model expression, and
recall that E{w[n]} = 0)
(Hint:
E{x[n]} = x̂[n] = E {ak−1,1 x[n − 1] + · · · + ak−1,k−1 x[n − k + 1] + w[n]} =
ak−1,1 x[n − 1] + · · · + ak−1,k−1 x[n − k + 1]) )
whether the process is an AR or not
c Danilo P. Mandic
Digital Signal Processing 35
Model order for Sunspot numbers
100
Signal values
0.5
Correlation
50
0
0
−50 −0.5
0 100 200 300 0 10 20 30 40 50
Sample Number Correlation lag
Partial ACF for sunspot series Burg Power Spectral Density Estimate
Power/frequency (dB/rad/sample)
1 35
30
0.5
25
Correlation
0 20
15
−0.5
10
−1 5
0 10 20 30 40 50 0 0.2 0.4 0.6 0.8 1
Correlation lag Normalized Frequency (×π rad/sample)
c Danilo P. Mandic
Digital Signal Processing 36
Model order for AR(2) generated process
4 0.5
Signal values
Correlation
2
0 0
−2
−4 −0.5
−6
−8 −1
0 100 200 300 400 500 0 10 20 30 40 50
Sample Number Correlation lag
Partial ACF for AR(2) signal Burg Power Spectral Density Estimate
Power/frequency (dB/rad/sample)
0.8 15
0.6 10
0.4
5
Correlation
0.2
0
0
−5
−0.2
−10
−0.4
−0.6 −15
−0.8 −20
0 10 20 30 40 50 0 0.2 0.4 0.6 0.8 1
Correlation lag Normalized Frequency (×π rad/sample)
c Danilo P. Mandic
Digital Signal Processing 37
Model order for AR(3) generated process
5 0.8
Signal values
Correlation
0 0.6
−5 0.4
−10 0.2
−15 0
0 100 200 300 400 500 0 10 20 30 40 50
Sample Number Correlation lag
Partial ACF for AR(3) signal Burg Power Spectral Density Estimate
Power/frequency (dB/rad/sample)
0.4 30
0.2
20
0
Correlation
10
−0.2
−0.4
0
−0.6
−10
−0.8
−1 −20
0 10 20 30 40 50 0 0.2 0.4 0.6 0.8 1
Correlation lag Normalized Frequency (×π rad/sample)
c Danilo P. Mandic
Digital Signal Processing 38
Model order for a financial time series
From:- http://finance.yahoo.com/q/ta?s=%5EIXIC&t=1d&l=on&z=m&q=b&p=v&a=&c=
Nasdaq ascending Nasdaq descending
Nasdaq composite June 2003 − February 2007 Nasdaq composite February 2007 − June 2003
2600 2600
2400 2400
Nasdaq value
Nasdaq value
2200 2200
2000 2000
1800 1800
1600 1600
1400 1400
0 500 1000 1500 2000 0 500 1000 1500 2000
Day number Day number
ACFx of
10 Nasdaq composite June 2003 − February 2007
7 ACFx of
10 Nasdaq composite June 2003 − February 2007
7
7 7
6 6
5 5
4 4
ACF value
ACF value
3 3
2 2
1 1
0 0
−1 −1
−2 −2
−3 −3
−2000 −1500 −1000 −500 0 500 1000 1500 2000 −2000 −1500 −1000 −500 0 500 1000 1500 2000
Correlation lag Correlation lag
c Danilo P. Mandic
Digital Signal Processing 39
Partial ACF for financial time series
a = 1.0000 -0.9994
c Danilo P. Mandic
Digital Signal Processing 40
Model Order Selection – Practical issues
In practice – the greater the model order the higher the accuracy
⇒ When do we stop?
p ∗ log(N )
M DL = log(E) +
N
AIC = log(E) + 2p/N
c Danilo P. Mandic
Digital Signal Processing 41
Example:- Model order selection – MDL vs AIC
Let us have a look at the squared error and the MDL and AIC criteria for
an AR(2) model with
a1 = 0.5 a2 = −0.3
MDL for AR(2)
1
MDL
0.98 Cumulative Squared Error
0.96
0.94
0.92
0.9
0.88
1 2 3 4 5 6 7 8 9 10
0.96
0.94
0.92
0.9
0.88
1 2 3 4 5 6 7 8 9 10
AR(2) Model Order
c Danilo P. Mandic
Digital Signal Processing 42
Moving Average Processes
A general MA(q) process is given by
x[n] = w[n] + b1w[n − 1] + · · · + bq w[n − q]
c Danilo P. Mandic
Digital Signal Processing 43
Example:- MA(3) process
1
2
0.8
Signal values
Correlation
1
0.6
0.4
0
0.2
−1
0
−2 −0.2
0 100 200 300 400 500 0 10 20 30 40 50
Sample Number Correlation lag
Partial ACF for MA(3) signal Burg Power Spectral Density Estimate
Power/frequency (dB/rad/sample)
0.5 −4
0.4
−6
0.3
−8
Correlation
0.2
0.1 −10
0
−12
−0.1
−14
−0.2
−0.3 −16
0 10 20 30 40 50 0 0.2 0.4 0.6 0.8 1
Correlation lag Normalized Frequency (×π rad/sample)
c Danilo P. Mandic
Digital Signal Processing 44
Analysis of Nonstationary Signals
Speech Signal
1
W1 W2 W3
Signal values
0.5
0
2000 3000 4000 5000 6000 7000 8000 9000 10000
Sample Number
Partial ACF for W1 Partial ACF for W2 Partial ACF for W3
0 1 1
−1 0.5 0.5
Correlation
Correlation
Correlation
1 0 0
0 −0.5 −0.5
−1 −1 −1
0 25 50 0 25 50 0 25 50
Correlation lag Correlation lag Correlation lag
MDL calculated for W1 MDL calculated for W2 MDL calculated for W3
1 1 1
MDL
MDL
0.6 0.5 0.6
0.4 0.4
0.2 0 0.2
0 25 50 0 25 50 0 25 50
Model Order Model Order Model Order
c Danilo P. Mandic
Digital Signal Processing 45
Duality Between AR and MA Processes
ii) The finite MA(q) process has an ACF that is zero beyond q. For an AR
process, the ACF is infinite in extent and consits of mixture of damped
exponentials and/or damped sine waves.
c Danilo P. Mandic
Digital Signal Processing 46