DSP II - Up To 28th Nov
DSP II - Up To 28th Nov
(EEE 431)
28-Nov-23 1
Why Study DSP-II
In Continuous-time Signals and Linear Systems and DSP-I Courses
You have mostly learned mathematical tools but
No Solid Techniques
for Solving Real-world Problems
By calculating the PSD of a signal, Overall, PSD is a powerful tool that allows
we can gain insight into the relative us to better understand the characteristics
strength of different frequency of a signal and make informed decisions4
components. about how to process or analyze it.
Why called power density spectrum?
Wiener-Khintchine Theorem:
Inv. 1
j
Px (e ) r (k )e
k
x
jk
rx (k )
2 P (e
x
j
)e jk
d
Ideal ACF
Parseval’s Relation
For k = 0,
6
Applications of power spectral density
Vibration and structural
Audio and acoustics analysis
PSD is often utilized in audio and acoustics PSD is valuable in understanding the
applications, such as determining the behavior of mechanical systems,
frequency response of a microphone or particularly in the context of vibration
analyzing the spectral content of music. In analysis. It can be used to identify
the music industry, PSD is used to analyze resonant frequencies, determine the
the frequency content of a song, which can amount of damping in a system, and
help in the mixing and mastering process. more. In the automotive industry,
It is also a key player in areas like noise PSD is used to analyze the vibration
reduction and speech enhancement. In the of a car's engine and chassis, which
field of acoustics, PSD is used to analyze can help in the design of a more
the sound pressure level and frequency comfortable and efficient vehicle. In
response of a room or building, which can the field of civil engineering, PSD is
help in the design of sound systems and used to analyze the vibration of
the mitigation of noise pollution. buildings and bridges, which can
help in the design of more resilient
7
structures.
Applications of power spectral density
a p
p a p T
(a Ra) 2Ra
a
9
Periodogram
Modified Periodogram
Bartlett method
Welch method
Blackman –Tucky method
11
Introduction
12
Introduction
13
Introduction
14
Introduction: Review of Statistics
15
Introduction: Review of Statistics
16
Introduction: Review of Statistics
17
Introduction: Review of Statistics
18
Ergodic Signals
Ensemble averages
can be replaced by
time averages
Stationary Signals
?
Will it be also a frequency-domain representation of the random
process x(n)?
23
The Periodogram
- Assumes that the observed signal is a truncated
version of the originally intended signal x(n)
- Truncate the sample function to use FT technique
= 0, |n|>N
- Asymtotically unbiased estimator of the PSD
Finite
duration
24
Classical Methods: The Periodogram
The ideal power spectrum of a WSS random
process x(n) is the DTFT of the ACF,
1
j
Px (e ) r ( k )e
k
x
jk
rx (k )
2 P (e
x
j
)e jk
d
Ideal ACF
For an ergodic process
N
1
rx (k ) E (n) x ( n k ) lim
*
x (n) x ( n k )
*
N 2 N 1
n N
DTFT
Unbiased estimate of ACF see the limit
1 N 1
rˆx (k )
N k n 0
x(n k ) x(n), k 0
- More reliable than the unbiased one, because it assigns lower weights
to the poorer estimates of long correlation lags (at least not increasing)
- Guarantees positive semi-definiteness of the correlation matrix, 𝒙
- Unbiased estimate may lead to –Ve value of the PS
- Periodogram = Correlogram for biased estimate
27
Periodogram (Cont.)
Let xN(n) be a finite sequence related to x(n) as
xN (n) wR (n) x(n)
Then the estimated ACF is
1 1
rˆx (k )
N
n
x N ( n k ) x N ( n) x N ( k ) * x N ( k )
N
Taking the DTFT:
ˆ j 1 j j 1 j 2
Pper (e ) X N (e ) X N (e ) | X N (e ) |
*
N N
where N 1
j
X N (e ) x
n
N ( n)e jn
x ( n)e
n0
jn
DFT 1 ˆ j 2 k / N 28
Implementation: x N ( n ) X N ( k ) | X N ( k ) | Pper ( e
2
)
N
Periodogram (Cont.)
2nd Definition: x(n), n 0,1,....., N
Given a finite
random sequence
29
True PSD
2. Asymptotically unbiased if
3. Consistent if
biased
) ),
Now,
) )= )
31
- So biased ACF estimator is asymptotically Unbiased
Performance of Periodogram: Bias
N 1
Pˆper (e j )
k N 1
rˆx (k )e jk
1 N 1 k
1 N 1 k
N k
E rˆx (k )
N
n0
E x(n k ) x(n)
N
n0
rx (k )
N
rx (k )
k
rx (k ) wB (k )e jk
* Periodic Conv.
where FT of Bartlett window is:
2
j1 sin( N / 2)
WB (e ) sin( / 2)
N
Note: The bias is zero if N infinity, because becomes an impulse 33
Performance of Periodogram:Bias (Cont.)
The Bartlett window can be obtained from the Rectangular window as:
*
Length of is
So the Periodogram is a biased estimator, since the expected value of is
not equal to However, since ,
the periodogram is asymptotically Unbiased
34
*
Performance of Periodogram: Variance
For a Gaussian white noise process, v(n)
[ independent of N ]
constant
Thus the variance does not go to zero as, and the periodogram is
NOT a consistent estimate of the power spectrum.
For sequences other than Gaussian white noise, e.g., x(n)
) for a regular Gaussian RP
Example: Calculate the periodogram of unity variance White Noise sequence x(n)
and comment on the performance of the estimator.
35
Example 8.2.1 (Hayes): Periodogram
of White Noise
36
Home work
Example: White Noise
*
Here
* Periodic Conv.
The width of the main lobe of increases as the data record length
decreases. For a data record length N, there is a limit on how closely two
sinusoids or two narrowband processes may be located before they can no
longer be resolved.
One way to define this resolution limit equal to the width of the main lobe of
the spectral window, , at its half-power 6dB point, equivalent to the 3
dB bandwidth of the data window, , given by
38
Rule of thumb
3dB (Half Power)
39
Assignment: Determine Mean of
Periodogram
Consider a random sinusoids:
True ACF
True PSD
40
Assignment: Determine Mean of
Periodogram (Cont.)
Now, *
𝟐 𝒋𝝎 ( (
𝑩
𝟐 𝒋𝜽 ( (
𝑩
Note: 41
Assignment: Determine Mean of
Periodogram (Cont.)
42
Example: What is the min N to
Resolve?
Consider a random signal of TWO sinusoids:
noise power
43
44
45
Modified Periodogram
Rectangular window
BIASED as,
*
- Need to get UNBIASED estimate but IMPOSSIBLE!!!
- Other window functions, e.g., Bartlett, Hamming and Hanning may be used
to obtain modified periodogram to reduce side lobe leakage
Assignment: Compare the performance of periodogram and modified periodogram
using a suitable example. Check resolution and variance for different window functions.
Note: 46
The Modified Periodogram: Bais (Cont.)
Note:
Now,
47
The Modified Periodogram: Bais (Cont.)
Thus,
*
PS of the window
gives biased estimate
48
The Modified Periodogram: Bias
Now,
*
Data window:
49
Asymptotically Unbiased
Window Properties
50
Modified Periodogram (Cont.)
Var
51
PSD of two sinusoids in noise
almost masked by
side lobes without data window
modulating
N 1
j
j sin( N / 2)
WR (e ) e 2
sin( / 2)
54
Periodogram – Viewed as Filter Bank
Now the output of the i-th filter is:
causal & finite
55
Improving the Spectral Estimate:
Bartlett’s Method
Reduce the variance of the periodogram by averaging a
number of different periodograms
Variance of the periodogram estimator does not imrpove
with greater lengths of data
into L non-overlapping
segments
i=1
i =1,2,……,K
Bartlett’s Method: Statistical Properties
BIAS:
because adding K
times the expected value
then dividing by K will
give the same result
Now, *
same as the Periodogram
So, * data length N or L makes
No difference
58
Bartlett’s Method: Statistical Properties
Thus if both K and L are allowed to go to infinity as
59
Overlay plot of 50 Periodograms for
Note: 61
The Welch Method (Cont.)
Let, the length of the segment be L, and the offset of successive sequences
is D samples. Then
where K is the no. of sequences that cover the entire N data points.
K sequences 62
Welch’s Method: Statistical Properties
BIAS:
because adding K
times the expected value
then dividing by K will
give the same result
Now, *
same as the Periodogram
data length N or L makes
No difference
Gain in:
- the variance of the Welch’s method is 9/8 times > Bartlett’s method
- Better resolution as the length is 2L
But for fixed N, and resolution (same L), 50% overlap, & Bartlett window
Bartlett’s method
Example: Repeat the previous example for 50% and 75% OVERLAP
Resolution:
Since the Modified Periodograms used in are computed using sequences
of length L, then the resolution is
= ,
=
=0, |k|>M
DTFT of product w(k) may be a Bartlett window
67
Blackman-Tukey Method (Contd.)
Because
If N, M goes to infinity
Variance: Var
Var
Trade-off between resolution and variance
M should be large to minimize the width of the mail lobe
1
M should be small in order to minimize the sum 𝑤 (𝑘)
𝑁
71
Minimum Variance Spectral Estimation
Normalized filter
Bandwidth
72
Minimum Variance Spectral Estimation
The MV spectrum estimation involves the following steps:
74
Design of the Narrowband Filter,
The output of the filter is then given by:
75
Design of the Narrowband Filter,
Minimize the Matrix Form (for each i)
Min
To ensure that the filter does not alter the power in the input
Process at freq. , will be constrained to
Min 𝒊 𝒊
subject to
77
Design of the Narrowband Filter,
78
Design of the Narrowband Filter,
79
data dependent
Design of the Narrowband Filter,
&
Hermitian symmetric
matrix
80
Design of the Narrowband Filter,
81
MVSE (Cont.)
Since the foregoing analysis holds for any choice of the centre
frequency , the MV spectral estimation is given by
where,
83
MVSE (Cont.)
Thus for a random process x(n)
85
this two definition has
transpose relation
86
Design of the Narrowband Filter,
87
Comments on MV Spectral Estimation
Implementation of MVSE:
Generally done directly on the data matrix X
for efficiency
Even with that, it is more complex than
Classical Methods
Performance of MVSE:
Provides better resolution than Classical
Methods
Mostly used when spiky spectra are expected
- AR method may be better
88
Model-based Spectral Estimation
Why parametric method?
Don’t require infinite AC sequence as periodogram
does. Modeling the infinite AC sequence by a finite
parameter model.
Px ( z ) Pu ( z ) Ph ( z )
Therefore, the output signal power spectrum is given by
j j j
Px (e ) Pu (e ) Ph (e ) 2
B(z) 2
u2 H ( z ) H * ( z ) |z e j P(z) u, z exp( j2f )
A(z)
u2 | H ( z ) |2 z e j u2 1
90
Parametric Methods
1 1
AR Method PˆAR (e j ) 2
p
| A( z ) |
|1 aˆk e jk |2
k 1
p
MA Method PˆMA (e j ) | B( z ) |2 |1 bˆk e jk |2
k 1
2 |1 bˆk e jk |2
| B ( z ) |
ARMA Method PˆARMA (e j ) 2
k 1
p
| A( z ) |
|1 aˆk e jk |2
k 1
‘System
Linear Models
identification deals
AR models
with the
MA models
mathematical ARMA models
modeling of
Additive
physical systems’ noise
Input
signal Linear System + Observed
signal
Spectral
Applications Estimation
Speech Modeling 92
Communications &
Control
93
Blind AR System Identification Techniques
Yule-Walker/
Autocorrelation ARMA model Input-Output Equation
Method p q
x(n) ai x(ni) bju(n j)
The picture can't be display ed.
Prediction Error
Method i1 j0
a LS R r 1
p
x (n) ai x(n i )
a LS R 1
i x1 rx x x
e( n ) x ( n ) x ( n ) where
rxx (0) rxx (1) rxx ( p 1) a1 rxx (1)
x(n) a x(n 1) T r (1)
xx rxx (0)
rxx ( p 2) a2 r (2)
xx
Cost function rxx ( p 1) rxx ( p 2) rxx (0) a p rxx ( p)
N 1
1
J LS
N
e
n 0
2
( n) USE
J MSE E[ x(n) aT x(n 1)]2 T
[a R x a] 2R x a
a
J LS
Setting 0 T
a xx
a
97
a
98
99
100
101
102
103
104
MA model identification
x(n) B( z )u (n)
B( z ) b0 b1 z 1 bq z q u (n) B( z )
1 x(n)
2 q m C ( z)
u bk bk m ,0 m q
k 0
Rxx (m) 0, m q
R (m), m 0 Rxx (0) u2 [b02 b12 b22 b32 ]
xx
Rxx (1) u2 [b0b1 b1b2 b2b3 ]
Difficulty: nonlinear equations
Rxx (2) u2 [b0b2 b1b3 ]
Example for an MA(3) system
Rxx (3) u2b0b3
b0u(n) b1u(n 1) b2u(n 2) b3u(n 3)
Rxx (0) b0u(n) b1u(n 1) b2u(n 2) b3u(n 3)
Rxx (1) b0u(n1) b1u(n2) b2u(n3) b3u(n4)
Rxx (2) b0u(n2) b1u(n3) b2u(n4) b3u(n5)
Rxx (3) b0u(n3) b1u(n4) b2u(n5) b3u(n6) 105
ARMA Model Identification
ARMA model I/O relation
p q
u (n) B(z) x(n) z (n)
x(n) ax
i (n i) bku(n k) A(z)
i1 k0 A(z)
pp qq AR approximation of the MA part:
m))
aaiiRRxxxx((mmii))
bbkkRRuxux((mmkk))
B( z )C ( z ) 1
RRxx
xx((m
ii11 kk00
For m > q
AR approximation of the ARMA model:
p
Rxx (m) ai Rxx (m i ) B( z )C ( z ) A( z )
i 1
AR Parameters of the ARMA system: A( z)
B(z)
C( z)
R xx ( q ) Rxx ( q 1) R xx ( q p 1) a1 Rxx ( q 1)
R ( q 1)
R xx ( q ) Rxx ( q p 2) a2 R ( q 2) Use: polynomial
xx xx
division
106
Rxx ( M 1) Rxx ( M 2) Rxx ( M p ) a p R
xx ( M )
DFT in Spectrum Estimation
N-point data
Direct Method
sequence x(n) 2
N-point (min) DFT S xx f X ( f ) x ( n )e
2 j 2 fn
n
N 1 2 Indirect Method
k 1
Pxx
N N
x
n 0
( n ) e j 2 kn / N
S xx f
r xx ( k ) e j 2 fk
k
k 0,1,...., N 1
k 2 where
f k , or , k k
N N Sparse
Sampling rxx ( k ) x ( n )x ( n k )
n
Zero Padding for interpolation
L 1 2
k 1
Pxx
L N
x ( n ) e j 2 kn / L
,L N 107
Yule-Walker method
p
Rxx (k ) al Rxx (k l ), for k 0
l 1
Noisy observation
y ( n) x ( n) v ( n)
Assumption u(n) & v(n) are uncorrelated
estimator
Different PSD Estimators
N 1 2
1
Direct method PPER( f )
N
x(n) exp( j2fn)
Conventional n0
methods N m1
1
Indirect
Rˆxx (m)
N n0
x(n m) x(n)
method N 1
u2 1
Order Selection of AR & ARMA Models
2 N P 1
FPE (Final Prediction FPE( p ) u ( p )
N p 1
Error)
2P
AIC (Akaike AIC( p) ln(u2( p))
N
Information Criterion)
2
MDL (Minimum ( p) Nln(u(p)) plnN
MDL
Description Length)
CAT (Criterion
Autoregressive
Transfer)
112
Examples on System Identification
a1=-1.8, a2=0.97
a1=-0.55, a2=-0.155, a3=0.5495, a4=-0.6241
a1=-2.7607, a2=3.8106, a3=-2.6535, a4=0.9238
b1=0.493, b2=0.433
b1=-1.8, b2=0.97
113
Model based Spectral Estimation
x2=x;
N=2048; x1=x;
Nd=4000; sizeR=p+1;
n=0:Nd-1; lenLag=Nd;
x=2*sin(2*pi/5*n) + for pos=1:sizeR;
4*sin(2.8*pi/5*n); a = x2(pos:lenLag);
Q1=0; b = x1(1:lenLag-pos+1);
p=4; r(pos)= a*b';
X=1/N*abs(fft(x,N)); end
k=0:N-1;
f=k./N; r= r./lenLag;
NF=max(X); R= toeplitz(r(1:sizeR-1));
plot(f,X/NF,'-or') par_est=-inv(R)*r(2:sizeR)'
A=[1 par_est'];
H=freqz(1,A,N,'whole');
NF=max(abs(H));
plot(f,abs(H)/NF,'-+k') 114
k_est=KPAR(x,Nd,p,Q1)';
[MA,AR] = ktar(k_est,p,Q1);
H=freqz(1,AR,N,'whole');
NF=max(abs(H));
plot(f,abs(H)/NF,'-xg')
grid
hold off
115
p = length(A1)-1;
overfit=0;%% 1 order over-fit gives better results in MA
no_of_pole = max(size(A)) - 1+overfit;
Q1 = max(size(B)) - 1;
% ----------------------------------
% -----Generating random signal-----
% ----------------------------------
%randn('state', 5);
u = randn(1, Nd);
U1 = 2*u/sqrt(cov(u));
% -----The generated signal is X-----
x = filter(B, A, U1);
116
A0 = [1]; B1 = [1];
A1 = [1 -0.6500 -0.7200 0.7600];%%S3 B2 = [1 0.433 0.49];
A2 = [1 -2.299 2.1262 -0.7604];%%%S4 B3 = [1 -0.5 0.785]; %%%S1
A3 = [1 -0.5500 0.1550 -0.5495 B4 = [1 0.76 0.85];%%%S3
0.6241];%%S1 B5 = [1 1.8 0.97];
A4 = [1 -2.595 3.339 -2.2 .731]; B6 = [1 -1.8 0.97]; %%%S2
A5 = [1 -0.86 1.0494 -0.668 0.9592 -0.7563 B7 = [1 -0.87 0.92];%%%S4
0.5656];
A6 = [1 -2.7607 3.8106 -2.6535 B8 = [1 0.556 0.81];
0.9238];%%S2
A7 = [1 -0.96 1.1494 -0.868 0.9092 -0.5563 B9 = [1 1.5 0.8];
0.4656]; B10 = [1 0 0.732];
% A8 = [1 -2.265 2.572 -1.837 0.656]; B11 = [1 0.4 0.2 0.15 0.26];
A9 = [1 0.479 0.086 0.29 0.731];
A11 = [1 -0.5 -0.61 .585]; %%%%%%%%%%%%%%%%Select
A12 = [1 -.45 -0.68 0.6175]; system%%%%%%%%%%%%
A13 = [1 0.6 -0.2975 -0.1927 .6329 .7057]; A = A1;
A14 = [1 -0.5500 -0.1550 0.5495 -0.6241]; B = B1;
A15 = [1 -.8484 1.6590 -.7372 1.4044 -.5556
.6236];
A16 = [1 -0.73 0.127 0.533 -0.81];
117
Examples:
118
Results
119
120
The roots of the predictor polynomial
The denominator of the transfer function
may be factored: 1 a z k 1 c z 1
p p
k 1
k k 1
k
F
Bˆ k s ln ck
If the pole is close to the unit circle then the root
represents a formant.
if rk Imck Reck 0.7
2 2
121
Line spectral pairs
The LP polynomial can be
decomposed into two (p+1) - order polynomials:
P z Q z
A z
2
122
Now:
• All the roots of P(z) and Q(z) lie on the unit circle
• P(z) corresponds to the vocal tract with the glottis closed
and Q(z) with the glottis open
• The roots of P(z) and Q(z) are interspersed except with
P having only a real zero at z=-1, and Q a zero at z=1
• The zeros comprise the LSP parameters and the name
derives from the fact that each zero pair corresponds to a
pole pair in the forward model, which lies on the unit
circle
• This pole pair would represent an undamped sinusoid
123
• Since zeros occur in complex conjugate pairs, only p
unique zeros are needed to specify the model
• the zeros are found through an iterative search along the
unit circle. Further, although the zeros are complex, their
magnitudes are known to be unity, so that only a single
real parameter (the frequency or angle) is needed to
specify each one
• This makes LSP parameters very useful for speech
coding applications
124
Random Variable & Random Process
125
WSS: A random process x(n) is said to be wide sense
stationary if the following conditions are satisfied:
1. The mean of the process is a constant, mx(n) = mx, all n.
2. The autocorrelation rx(k,l) depends only on the difference,
k-l, i.e., rx(k,l) = rx(k-l) = rx(t), t = k-l, for all k and l
3. The variance of the process is finite, rx(0)< infinity.
126
Power Spectrum
Px ( z ) Px* ( z * )
127
Power Spectrum
P2: Positivity. The PS of a WSS random
process is nonnegative
j
Px (e ) 0
P3: Total power. The power in a zero
mean WSS random process is propotional
to the area under the power spectral
density curve
1
E | x( n) |
Px (e j )d
2
2
Find the power spectrum of a zero mean white noise v(n). 128
Parametric Methods
1 1
AR Method PˆAR (e j ) 2
p
| A( z ) |
|1 aˆk e jk |2
k 1
p
MA Method PˆMA (e j ) | B( z ) |2 |1 bˆk e jk |2
k 1
2 |1 bˆk e jk |2
| B ( z ) |
ARMA Method PˆARMA (e j ) 2
k 1
p
| A( z ) |
|1 aˆk e jk |2
k 1
129
Why parametric methods?
ryx (k ) E y (n k ) x(n) E h(l ) x(n k l )x(n)
l
h(l ) E x(n k l ) x(n)
l
ryx (k ) h(l )r (k l )
l
x
rx (k )* h(k )
131
ry (k ) E y (n k ) y (n)
E y (n k ) x(l )h(n l )
l
h(n l )E y(n k ) x(l )
l
h(n l )r
l
yx (n k l )
Setting m=n-k,
ry (k ) h ( m) r
m
yx (m k )
h(m)r
m
yx ( k m)
g (m)r
m
yx (k m) g (k ) * ryx (k ) h( k )* ryx (k ) 132
ry (k ) h( k ) * ryx (k )
h( k )* h(k )* rx (k )
rx (k ) * rh (k )
Taking the z-transform,
Py ( z ) Px ( z ) Ph ( z )
Therefore, the output signal power spectrum is given by
j j j
Py (e ) Px (e ) Ph (e )
H ( z)H ( z)
2
x
*
| H ( z) |
2
x
2
133