SSP 3 2 - Spectrum 2
SSP 3 2 - Spectrum 2
1 Introduction
6 Summary
1 / 50
2 / 50 3 / 50
Additional material Review of spectral estimation
Matlab manual: Multitaper power spectral density estimate Classical spectral estimation is Fourier based spectral estimation
Multitaper on wikipedia The periodogram is the Fourier transform of the biased autocorrelation estimate
Barry Van Veen on youtube: Estimation of Coherence and Cross spectra The periodogram spectral estimator suffers from unacceptable bias and variance
Matlab manual: Time-Frequency Analysis Bias can be reduced by tapering
Short Time Fourier Transform and Spectrogram on Wikipedia Variance can be reduced by averaging or smoothing
Time Frequency Toolbox: tftb.nongnu.org There is a trade-off between:
Variance reduction and spectral resolution
Large Time-Frequency Analysis Toolbox (LTFAT):
Bias reduction and spectral resolution
ltfat.sourceforge.net, sourceforge.net/projects/ltfat/
Bias and variance performance
Sverre Holm: Master thesis on Spectral analysis of sunspot data
https://www.mn.uio.no/fysikk/studier/master/masteroppgaver/
ELITE : signalbehandling og avbildning : spectral analysis of sunspot data
4 / 50 5 / 50
The modified periodogram: Bias reduction by tapering Welch’s method: Variance reduction by averaging
Bias can be reduced by applying tapering (or windowing). Variance can be reduced by averaging multiple modified periodograms.
At the cost of loss in spectral resolution. Does not affect variance. At the cost of loss in spectral resolution. Does not affect bias.
Bias due to sidelobes is referred to as spectral leakage. More or less equivalent to spectral smoothing.
6 / 50 7 / 50
Frequency resolution Multitaper spectral estimation
Inspired by the success of tapering and averaging, one could construct a new spectral estimator
The Periodogram is the Fourier based spectral estimator with best spectral resolution
2 as follows:
N −1
1 X
−j ω n
P̂xx (ω) = x (n)e multitaper algorithm
N
n=0
1 Construct several different tapers of size N (full size)
In frequency estimation (different from spectral estimation), this technique can be used
2 Ensure that the tapers are properly designed orthogonal functions
Assume a harmonic signal in additive white Gaussian noise 3 Produce modified periodograms using each taper (with low bias)
x (n) = A cos(ω0 n + ϕ) + w (n) 4 Average (with or without weighting) to reduce variance
with unknown amplitude A, frequency ω0 and phase ϕ.
Within certain bounds, maximizing the Periodogram is approximately the optimal frequency First suggested by Thomson in 1982
estimator Windows based on Discrete Prolate Spheroidal Sequences
It is the Maximum Likelihood Estimator (MLE), and attains the Cramér-Rao lower bound Matlab function pmtm for multitaper spectral estimator
(CRLB) asymptotically (for large N or SNR).
Matlab function dpss to produce the tapers
8 / 50 9 / 50
Each taper wk (n) must have low sidelobe level to prevent bias
(m,k )
The individual modified periodograms P̂xx (ω) must be pairwise uncorrelated such that
averaging reduces variance
10 / 50 11 / 50
Discrete Prolate Spheroidal Sequences (DPSS) Poor-mans multitapers
A simpler set of orthonormal tapers can be constructed from sinusoidal tapers (Reidel and
Design criterum: Choose the window function w (n) to obtain a transformed window W (ω)
Sidorenko 1995)
which maximizes
r
main lobe energy 2 π(k + 1)(n + 1)
max wk (n) = sin
w total energy N +1 N +1
No closed form solution
The DPSS are eigenfunctions with corresponding eigenvalues solving the integral equation
The Kaiser window is a simple approximation of the 0th order DPSS using Bessel functions
Orhtogonality between the tapers ensures that variance is reduced
See Window function on Wikipedia, and DPSS in the Matlab manual
12 / 50 13 / 50
14 / 50 15 / 50
Difficult case: Single tone in non-flat spectrum Example: Single tone in non-flat spectrum
Periodogram:
Create a single realisation of non-white noise by filtering WGN
P_per = 1/n .* abs(fft(x)).^2;
Add a transient single tone signal with low amplitude
Model Code
n = 1024*8; b = 1;
a = [1 -0.99, 0.9]; % Filter parameters
[h,faxe_m] = freqz(b,a,n); % Model spectrum
faxe_m = faxe_m / (2*pi);
P_model = abs(h).^2;
M = 1000; L = 100;
w = randn(L+n,1); % WGN
x = filter(b,a,w); % Filtered noise
x = x(L+1:L+n); % remove transient
Example: Single tone in non-flat spectrum Example: Single tone in non-flat spectrum
Welch’s method: Multitaper method:
[P_welch, faxe_w] = pwelch( x, kaiser(1024,5.5), 1024/4*3 ); [P_mtm,faxe_mtm] = pmtm(x,4);
18 / 50 19 / 50
Example: Single tone in non-flat spectrum: Zoomed Classical spectral estimation - Summary
The Welch and the multitaper method reduces variance and improves detectability The Periodogram:
The Fourier transform of the biased autocorrelation estimate.
The multitaper technique gives better sampling of the peak than Welch method Suffers from poor bias and variance. Good spectral resolution
The modified periodogram
Windowed (tapered) periodogram.
Bias reduced, Variance not reduced. Trade-off between spectral resolution and bias reduction.
Welch’s method (WOSA)
Divide data into small sections and estimate the spectrum.
Bias reduced, Variance reduced, Consistent.
Heavy trade-off between spectral resolution and Variance reduction.
Thomson’s multitaper method
Apply different windows of full length and estimate the spectrum.
Bias reduced, Variance reduced, Consistent.
Also trade-off between spectral resolution and Variance reduction.
20 / 50 21 / 50
Estimation of the Magnitude Squared Coherence The MSC and the Periodogram 1
Magnitude squared coherence (MSC) Consider two zero mean WSS random sequences x (n) and y (n)
|Pxy (ω)|2 The periodogram
|Γxy (ω)|2 = , 0 ≤ |Γxy (ω)|2 ≤ 1
Pxx (ω)Pyy (ω) 1 1
P̂xx (ω) = XN∗ (ω)XN (ω) = |XN (ω)|2
Requires Pxx (ω) > 0 and Pyy (ω) > 0 N N
where XN (ω) is the discrete Fourier transform of x (n)
Frequency domain analog of the correlation coefficient
Correspondingly for y (n)
Assess the relationship between two signals in frequency domain
1 1
P̂yy (ω) = YN∗ (ω)YN (ω) = |YN (ω)|2
Can be used to prove linear dependence N N
Reference: Bendat & Piersol 1980 The periodogram estimator of the cross spectrum
1
How to estimate it? Similar procedure as for the PSD. P̂xy (ω) = XN∗ (ω)YN (ω)
N
Barry Van Veen on youtube: Estimation of Coherence and Cross spectra
22 / 50 23 / 50
The MSC and the Periodogram 2 Estimating the MSC
Inserting into the MSC Use a better spectral estimator instead of the periodogram
Suggestion: use the Welch overlapped segment averaging
|P̂xy (ω)|2
|Γ̂xy (ω)|2 = K −1
P̂xx (ω)P̂yy (ω) (w ) 1 X (m,i )
P̂xx (ω) = P̂xx (ω)
|XN∗ (ω)YN (ω)|2 XN∗ (ω)YN (ω) XN (ω)YN∗ (ω) K
i =0
= = =1
XN∗ (ω)XN (ω) YN∗ (ω)YN (ω) XN∗ (ω)XN (ω) YN∗ (ω)YN (ω) (m,i )
P̂xx (ω) is the i-th modified periodogram
2 (w ) (w )
The MSC is estimated to |Γ̂xy (ω)| = 1, independent of data Correspondingly for P̂yy and P̂xy
From Manolakis, p239: The frequency domain correlation coefficient at each frequency is Inserting into the MSC
estimated using only one single pair of observations from the two signals. (w )
|P̂xy (ω)|2
|Γ̂xy (ω)|2 =
The periodogram cannot be used in estimating the MSC (w )
P̂xx (ω)P̂yy (ω)
(w )
26 / 50 27 / 50
Example time-frequency representation Short time Fourier transform
Divide the total sequence of N data samples into
segments of size L, and offset each segment by D
points into a total number of K segments such that
N = L + D (K − 1)
The Short Time Fourier Transform is
L− 1
X
STFT(i , ω) = x (n + iD )w (n)e−j ωn
n =0
where w (n) is a window of choice.
Note the similarity with Welch’s method of
periodogram averaging
Also known as sliding window Fourier transform
From wikipedia.org
The spectrogram is commonly known as the magnitude squared STFT
28 / 50 29 / 50
Short time Fourier transform Time and frequency resolution in the STFT
The STFT can be generalised to use any Fourier based spectral estimator
The uncertainty principle states that the time duration ∆t and frequency bandwidth ∆ω are
Example: Spectrogram based on the modified periodogram related by
2
1
L−1
1 X
∆t ∆ω ≥
P̂xx (t , ω) = x (n + iD )w (n)e−j ωn , t = (i + D /2)δ t
L 2
n =0
A fundamental property of the Fourier transform pair s(t ) and S (ω)
where δ t is the sampling interval
Derived by Heisenberg in 1927 in quantum mechanics (for position and momentum)
See spectrogram, stft, istft in Matlab
Caution
STFTs should really be viewed as a stack of individual spectral estimates. To construct a
proper density P (t , ω) as a function of time and frequency, energy conservation has to be
taken into account. This is not the case for STFT-based representations.
Werner Heisenberg
theoretical physicist
Nobel prize 1932
From wikipedia
30 / 50 31 / 50
Time and frequency resolution in the STFT Example: STFT of FM signal
The time-frequency resolution relation leads to the following: Consider a simple deterministic mono-component signal
Better frequency resolution requires larger time duration and thereby lower time resolution a1
s(t ) = a(t )ej ϕ(t ) , ϕ(t ) = ω0 t + cos(ω1 t )
Better time resolution requires shorter time duration and thereby lower frequency resolution ω1
32 / 50 33 / 50
34 / 50 35 / 50
A dirty trick: Zeropadding Zeropadding example: STFT of FM signal
A simple trick to get smoother spectral representation is zeropadding
Zeropadding is adding zeros in the sequence to be FT ed
Done in Matlab for you: fft(x, N) will zeropad the sequence x to a total of N elements
before FT is applied
36 / 50 37 / 50
38 / 50 39 / 50
Example: Human voice Example: Hydrophone data
Data from the Lofoten - Vesterålen (LoVe) Ocean Observatory hydrophone. Data taken 2018-01-21, approximately 06:00
Audio demo From scholarpedia.org
42 / 50 43 / 50
Second order Time-frequency representations Second order Time-frequency representations
The uncertainty principle limits directly the ability to resolve transient This approach has a number of desirable properties
frequencies in the STFT It obtains “full” resolution for LFM type signals
It is energy preserving (and as such a proper distribution)
How do we approach this?
It does however, produce cross terms (ghosts)
We capture the time variantion (non-stationarity) into a time-varying
A generalised form (referred to as Cohen’s class) is
autocorrelation function
C (t , ω) = W (t , ω) ∗ Φ(t , ω)
Rxx (t , τ ) = x (t + τ /2)x ∗ (t − τ /2)
where the kernel function Φ(t , ω) can be chosen
and directly transform into time-frequency domain
The generalised form describe any time-frequency representation (including STFT)
The Wigner-Ville distribution does this
By choosing the kernel function, the cross terms can be supressed at the cost of loss in
Z
W (t , ω) = x (t + τ /2)x ∗ (t − τ /2)e−j ωτ d τ resolution
Eugene Wigner
Introduced by Wigner in 1932 in quantum mechanics, and introduced to physicist / mathematican Time-Frequency Toolbox for Matlab: http://tftb.nongnu.org/
Nobel prize 1963
signal analysis by Ville in 1948 From wikipedia
wvd in matlab signal processing toolbox
44 / 50 45 / 50
46 / 50 47 / 50
Time-frequency representation of a FM signal Fourier synchrosqueezed transform
Choi-Williams distribution
New approach that treats the problems with the STFT and second order T-F methods.
Uses phase to sharpen up the T-F representation, and is invertible.
In matlab: fsst, ifsst, Signal Analyzer
See also (in matlab): spectrogram, pspectrum and reassigned
Auger et al. Time-Frequency Reassignment and Synchrosqueezing. IEEE Signal Processing Magazine November 2013
48 / 50 49 / 50
50 / 50