Documentation Center

  • Trials
  • Product Updates

pmtm

Multitaper power spectral density estimate

Syntax

  • [pxx,w] = pmtm(___)
  • [pxx,f] = pmtm(___,fs) example
  • [pxx,w] = pmtm(x,nw,w)
  • [pxx,f] = pmtm(x,nw,f,fs)
  • [___] = pmtm(x,e,v) example
  • [___] = pmtm(x,dpss_params)
  • [___] = pmtm(___,'DropLastTaper',dropflag) example
  • [___] = pmtm(___,freqrange) example
  • [pxx,f,pxxc] = pmtm(___,'ConfidenceLevel',probability) example
  • pmtm(___)

Description

example

pxx = pmtm(x) returns Thomson's multitaper power spectral density (PSD) estimate of the input signal, x. The tapers are the discrete prolate spheroidal (DPSS), or Slepian, sequences. The time-halfbandwidth, nw, product is 4. By default, pmtm uses the first 2nw–1 DPSS sequences. If x is real-valued, pxx is a one-sided PSD estimate. If x is complex-valued, pxx is a two-sided PSD estimate. The number of points, nfft, in the discrete Fourier transform (DFT) is the maximum of 256 or the next power of two greater than the signal length.

example

pxx = pmtm(x,nw) use the time-halfbandwidth product, nw, to obtain the multitaper PSD estimate. The time-halfbandwidth product controls the frequency resolution of the multitaper estimate. pmtm uses 2nw-1 Slepian tapers in the PSD estimate.

example

pxx = pmtm(x,nw,nfft) uses nfft points in the DFT. If nfft is greater than the signal length, x is zero-padded to length nfft. If nfft is less than the signal length, the signal is wrapped modulo nfft .

[pxx,w] = pmtm(___) returns the normalized frequency vector, w. If pxx is a one-sided PSD estimate, w spans the interval [0,π] if nfft is even and [0,π) if nfft is odd. If pxx is a two-sided PSD estimate, w spans the interval [0,2π).

example

[pxx,f] = pmtm(___,fs) returns a frequency vector, f, in cycles per unit time. The sampling frequency, fs, is the number of samples per unit time. If the unit of time is seconds, then f is in cycles/sec (Hz). For real–valued signals, f spans the interval [0,fs/2] when nfft is even and [0,fs/2) when nfft is odd. For complex-valued signals, f spans the interval [0,fs).

[pxx,w] = pmtm(x,nw,w) returns the two-sided multitaper PSD estimates at the normalized frequencies specified in the vector, w. The vector, w, must contain at least 2 elements.

[pxx,f] = pmtm(x,nw,f,fs) returns the two-sided multitaper PSD estimates at the frequencies specified in the vector, f. The vector, f, must contain at least 2 elements. The frequencies in f are in cycles per unit time. The sampling frequency, fs, is the number of samples per unit time. If the unit of time is seconds, then f is in cycles/sec (Hz).

example

[___] = pmtm(___,method) combines the individual tapered PSD estimates using the method, method. method can be one of: 'adapt' (default), 'eigen', or 'unity'.

example

[___] = pmtm(x,e,v) uses the tapers in the N-by-K matrix e with concentrations v in the frequency band [-w,w]. N is the length of the input signal, x. Use dpss to obtain the Slepian tapers and corresponding concentrations.

[___] = pmtm(x,dpss_params) uses the cell array, dpss_params, to pass input arguments to dpss except the number of elements in the sequences. The number of elements in the sequences is the first input argument to dpss and is not included in dpss_params. For example

x = randn(1000,1);
pxx = pmtm(x,{2.5,3});

example

[___] = pmtm(___,'DropLastTaper',dropflag) specifies whether pmtm drops the last taper in the computation of the multitaper PSD estimate. dropflag is a logical. The default value of dropflag is true and the last taper is not used in the PSD estimate.

example

[___] = pmtm(___,freqrange) returns the multitaper PSD estimate over the frequency range specified by freqrange. Valid options for freqrange are

: 'onesided', 'twosided', or 'centered'.

example

[pxx,f,pxxc] = pmtm(___,'ConfidenceLevel',probability) returns the probabilityx100% confidence intervals for the PSD estimate in pxxc.

pmtm(___) with no output arguments plots the multitaper PSD estimate in the current figure window.

Examples

expand all

Multitaper Estimate Using Default Inputs

Obtain the multitaper PSD estimate of an input signal consisting of a discrete-time sinusoid with an angular frequency of π/4 radians/sample with additive N(0,1) white noise.

Create a sine wave with an angular frequency of π/4 radians/sample with additive N(0,1) white noise. The signal is 320 samples in length. Obtain the multitaper PSD estimate using the default time-halfbandwidth product of 4 and DFT length. The default number of DFT points is 512. Because the signal is real-valued, the PSD estimate is one-sided and there are 512/2+1 points in the PSD estimate.

n = 0:319;
x = cos(pi/4*n)+randn(size(n));
pxx = pmtm(x);
plot(10*log10(pxx))

Specify Time-Halfbandwidth Product

Obtain the multitaper PSD estimate with a specified time-halfbandwidth product.

Create a sine wave with an angular frequency of π/4 radians/sample with additive N(0,1) white noise. The signal is 320 samples in length. Obtain the multitaper PSD estimate with a time–halfbandwidth product of 2.5. The resolution bandwidth is [-2.5π/320,2.5π/320] radians/sample. The default number of DFT points is 512. Because the signal is real-valued, the PSD estimate is one-sided and there are 512/2+1 points in the PSD estimate.

n = 0:319;
x = cos(pi/4*n)+randn(size(n));
pxx = pmtm(x,2.5);
plot(10*log10(pxx))

DFT Length Equal to Signal Length

Obtain the multitaper PSD estimate of an input signal consisting of a discrete-time sinusoid with an angular frequency of π/4 radians/sample with additive N(0,1) white noise. Use a DFT length equal to the signal length.

Create a sine wave with an angular frequency of π/4 radians/sample with additive N(0,1) white noise. The signal is 320 samples in length. Obtain the multitaper PSD estimate with a time-halfbandwidth product of 3 and a DFT length equal to the signal length. Because the signal is real-valued, the one-sided PSD estimate is returned by default with a length equal to 320/2+1.

n = 0:319;
x = cos(pi/4*n)+randn(size(n));
pxx = pmtm(x,3,length(x));
plot(10*log10(pxx))

Multitaper Estimate with Sampling Frequency

Obtain the multitaper PSD estimate of a signal sampled at 1 kHz. The signal is a 100-Hz sine wave in additive N(0,1) white noise. The signal duration is 2 seconds. Use a time-halfbandwidth product of 3 and DFT length equal to the signal length.

fs = 1000;
t = 0:1/fs:2-1/fs;
x = cos(2*pi*100*t)+randn(size(t));
[pxx,f] = pmtm(x,3,length(x),fs);
plot(f,10*log10(pxx))

Average Single-Taper Estimates with Unity Weights

Obtain a multitaper PSD estimate where the individual tapered direct spectral estimates are given equal weight in the average.

Obtain the multitaper PSD estimate of a signal sampled at 1 kHz. The signal is a 100-Hz sine wave in additive N(0,1) white noise. The signal duration is 2 seconds. Use a time-halfbandwidth product of 3 and DFT length equal to the signal length. Use the 'unity' option to give equal weight in the average to each of the individual tapered direct spectral estimates.

fs = 1000;
t = 0:1/fs:2-1/fs;
x = cos(2*pi*100*t)+randn(size(t));
[pxx,f] = pmtm(x,3,length(x),fs,'unity');
plot(f,10*log10(pxx))

DPSS Sequences and Their Frequency-Domain Concentrations

This example examines the frequency-domain concentrations of the DPSS sequences. The example produces a multitaper PSD estimate of an input signal by precomputing the Slepian sequences and selecting only those with more than 99% of their energy concentrated in the resolution bandwidth.

The signal is a 100-Hz sine wave in additive N(0,1) white noise. The signal duration is 2 seconds.

fs = 1000;
t = 0:1/fs:2-1/fs;
x = cos(2*pi*100*t)+randn(size(t));

Set the time-halfbandwidth product to 3.5. For the signal length of 2000 samples and a sampling interval of 0.001 seconds, this results in a resolution bandwidth of [-1.75,1.75] Hz. Calculate the first 10 Slepian sequences and examine their frequency concentrations in the specified resolution bandwidth. Determine the number of Slepian sequences with energy concentrations greater than 90%.

[e,v] = dpss(length(x),3.5,10);
stem(1:length(v),v,'markerfacecolor',[0 0 1]); set(gca,'ylim',[0 1.2])
title('Energy Concentrations in [-w,w] of k-th Slepian Sequence');
xlabel('k-th sequence'); ylabel('Proportion of Energy in [-w,w]');
h = line(1:length(v),0.990*ones(length(v),1));
set(h,'color','r','linewidth',2)
idx = find(v>0.99,1,'last');

Using the selected DPSS sequences, obtain the multitaper PSD estimate. Set 'DropLastTaper' to false to use all the selected tapers.

[pxx,f] = pmtm(x,e(:,1:idx),v(1:idx),length(x),fs,'DropLastTaper',false);
plot(f,10*log10(pxx))

DC-Centered Multitaper PSD Estimate

Obtain the multitaper PSD estimate of a 100-Hz sine wave in additive N(0,1) noise. The data are sampled at 1 kHz. Use the 'centered' option to obtain the DC-centered PSD and plot the result.

fs = 1000;
t = 0:1/fs:2-1/fs;
x = cos(2*pi*100*t)+randn(size(t));
[pxx,f] = pmtm(x,3.5,length(x),fs,'centered');
plot(f,10*log10(pxx))
xlabel('Hz'); ylabel('dB')

Upper and Lower 95%-Confidence Bounds

The following example illustrates the use of confidence bounds with the multitaper PSD estimate. While not a necessary condition for statistical significance, frequencies in the multitaper PSD estimate where the lower confidence bound exceeds the upper confidence bound for surrounding PSD estimates clearly indicate significant oscillations in the time series.

Create a signal consisting of the superposition of 100-Hz and 150-Hz sine waves in additive white N(0,1) noise. The amplitude of the two sine waves is 1. The sampling frequency is 1 kHz. The signal is 2 seconds in duration.

fs = 1000;
t = 0:1/fs:2-1/fs;
x = cos(2*pi*100*t)+cos(2*pi*150*t)+randn(size(t));

Obtain the multitaper PSD estimate with 95%-confidence bounds. Plot the PSD estimate along with the confidence interval and zoom in on the frequency region of interest near 100 and 150 Hz.

[pxx,f,pxxc] = pmtm(x,3.5,length(x),fs,...
'ConfidenceLevel', 0.95);
plot(f,10*log10(pxx)); hold on;
plot(f,10*log10(pxxc),'r--','linewidth',2);
axis([85 175 min(min(10*log10(pxxc))) max(max(10*log10(pxxc)))]);
xlabel('Hz'); ylabel('dB');
title('Multitaper PSD Estimate with 95%-Confidence Bounds');

At 100 and 150 Hz, the lower confidence bound exceeds the upper confidence bounds for surrounding PSD estimates.

Input Arguments

expand all

x — Input signalvector

Input signal, specified as a row or column vector.

Data Types: single | double
Complex Number Support: Yes

nw — Time-halfbandwidth product4 (default) | positive scalar

Time-halfbandwidth product, specified as a positive scalar. In multitaper spectral estimation, the user specifies the resolution bandwidth of the multitaper estimate [-W,W] where W=j/NΔt for some small j>1. Equivalently, W is some small multiple of the frequency resolution of the DFT. The time-halfbandwidth product is the product of the resolution halfbandwidth and the number of samples in the input signal, N. The number of Slepian tapers whose Fourier transforms are well-concentrated in [-W,W] (eigenvalues close to unity) is 2NW-1.

nfft — Number of DFT pointsmax(256,2^nextpow2(length(x)) (default) | integer | []

Number of DFT points, specified as a positive integer. For a real-valued input signal, x, the PSD estimate, pxx has length (nfft/2+1) if nfft is even, and (nfft+1)/2 if nfft is odd. For a complex-valued input signal,x, the PSD estimate always has length nfft. If nfft is specified as empty, the default nfft is used.

Data Types: single | double

fs — Sampling frequencypositive scalar

Sampling frequency specified as a positive scalar. The sampling frequency is the number of samples per unit time. If the unit of time is seconds, the sampling frequency has units of hertz.

w — Normalized frequencies for Goertzel algorithmvector

Normalized frequencies for Goertzel algorithm, specified as a row or column vector with at least 2 elements. Normalized frequencies are in radians/sample.

Example: w = [pi/4 pi/2]

Data Types: double

f — Cyclical frequencies for Goertzel algorithmvector

Cyclical frequencies for Goertzel algorithm, specified as a row or column vector with at least 2 elements. The frequencies are in cycles per unit time. The unit time is specified by the sampling frequency, fs. If fs has units of samples/second, then f has units of Hz.

Example: fs = 1000; f= [100 200]

Data Types: double

method — Weights on individual tapered PSD estimates'adapt' (default) | 'eigen' | 'unity'

Weights on individual tapered PSD estimates, specified as one of 'adapt', 'eigen', or 'unity'. The default is Thomson's adaptive frequency-dependent weights, 'adapt'. The calculation of these weights is detailed on pp. 368–370 in [1]. The 'eigen' method weights each tapered PSD estimate by the eigenvalue (frequency concentration) of the corresponding Slepian taper. The 'unity' method weights each tapered PSD estimate equally.

e — DPSS (Slepian) sequencesmatrix

DPSS (Slepian) sequences, specified as a N-by-K matrix where N is the length of the input signal, x. The matrix e is the output of dpss.

v — Eigenvalues for DPSS (Slepian) sequencesvector

Eigenvalues for DPSS (Slepian) sequences, specified as a column vector. The eigenvalues for the DPSS sequences indicate the proportion of the sequence energy concentrated in the resolution bandwidth, [-W, W]. The eigenvalues range lie in the interval (0,1) and generally the first 2NW-1 eigenvalues are close to 1 and then decrease toward 0.

dpss_params — Input arguments for dpsscell array

Input arguments for dpss, specified as a cell array. The first input argument to dpss is the length of the DPSS sequences and is omitted from dpss_params. The length of the DPSS sequences is obtained from the length of the input signal, x.

Example: {3.5,5}

dropflag — Flag indicating whether to drop or keep the last DPSS sequencetrue (default) | false

Flag indicating whether to drop or keep the last DPSS sequence, specified as a logical. The default is true and pmtm drops the last taper. In a multitaper estimate, the first 2NW-1 DPSS sequences have eigenvalues close to unity. If you use less than 2NW-1 sequences, it is likely that all the tapers have eigenvalues close to 1 and you can specify dropflag as false to keep the last taper.

freqrange — Frequency range for PSD estimate'onesided' | 'twosided' | 'centered'

Frequency range for the PSD estimate, specified as a one of 'onesided', 'twosided', or 'centered'. The default is 'onesided' for real-valued signals and 'twosided' for complex-valued signals. The frequency ranges corresponding to each option are

  • 'onesided' — returns the one-sided PSD estimate of a real-valued input signal, x. If nfft is even, pxx will have length nfft/2+1 and is computed over the interval [0,π] radians/sample. If nfft is odd, the length of pxx is (nfft+1)/2 and the interval is [0,π) radians/sample. When fs is optionally specified, the corresponding intervals are [0,fs/2] cycles/unit time and [0,fs/2) cycles/unit time for even and odd length nfft respectively.

  • 'twosided' — returns the two-sided PSD estimate for either the real-valued or complex-valued input, x. In this case, pxx has length nfft and is computed over the interval [0,2π) radians/sample. When fs is optionally specified, the interval is [0,fs) cycles/unit time.

  • 'centered' — returns the centered two-sided PSD estimate for either the real-valued or complex-valued input, x. In this case, pxx has length nfft and is computed over the interval (-π,π] radians/sample for even length nfft and (-π,π) radians/sample for odd length nfft. When fs is optionally specified, the corresponding intervals are (-fs/2, fs/2] cycles/unit time and (-fs/2, fs/2) cycles/unit time for even and odd length nfft respectively.

Data Types: char

probability — Confidence interval for PSD estimate0.95 (default) | scalar in the range (0,1)

Coverage probability for the true PSD, specified as a scalar in the range (0,1). The output, pxxc, contains the lower and upper bounds of the probabilityx100% interval estimate for the true PSD.

Output Arguments

expand all

pxx — PSD estimatevector

PSD estimate, specified as a real-valued, nonnegative column vector. The units of the PSD estimate are in squared magnitude units of the time series data per unit frequency. For example, if the input data is in volts, the PSD estimate is in units of squared volts per unit frequency. For a time series in volts, if you assume a resistance of 1 ohm and specify the sampling frequency in Hz, the PSD estimate is in watts/Hz.

Data Types: single | double

w — Normalized frequenciesvector

Normalized frequencies, specified as a real-valued column vector. If pxx is a one-sided PSD estimate, w spans the interval [0,π] if nfft is even and [0,π) if nfft is odd. If pxx is a two-sided PSD estimate, w spans the interval [0,2π). For a DC-centered PSD estimate, f spans the interval (-π,π] radians/sample for even length nfft and (-π,π) radians/sample for odd length nfft.

Data Types: double

f — Cyclical frequenciesvector

Cyclical frequencies, specified as a real-valued column vector. For a one-sided PSD estimate, f spans the interval [0,fs/2] when nfft is even and [0,fs/2) when nfft is odd. For a two-sided PSD estimate, f spans the interval [0,fs). For a DC-centered PSD estimate, f spans the interval (-fs/2, fs/2] cycles/unit time for even length nfft and (-fs/2, fs/2) cycles/unit time for odd length nfft .

Data Types: double

pxxc — Confidence boundsmatrix

Confidence bounds, specified as an N-by-2 matrix with real-valued elements. The row dimension of the matrix is equal to the length of the PSD estimate, pxx. The first column contains the lower confidence bound and the second column contains the upper confidence bound for the corresponding PSD estimates in the rows of pxx. The coverage probability of the confidence intervals is determined by the value of the probability input.

Data Types: single | double

More About

expand all

Discrete Prolate Spheroidal (Slepian) Sequences

The derivation of the Slepian sequences proceeds from the discrete-time — continuous frequency concentration problem. For all ℓ2 sequences index-limited to 0,1,...,N-1, the problem seeks the sequence having the maximal concentration of its energy in a frequency band [-W,W] with |W| < 1/2Δt.

This amounts to finding the eigenvalues and corresponding eigenvectors of an N-by-N self-adjoint positive semi-definite operator. Therefore, the eigenvalues are real and nonnegative and eigenvectors corresponding to distinct eigenvalues are mutually orthogonal. In this particular problem, the eigenvalues are bounded by 1 and the eigenvalue is the measure of the sequence's energy concentration in the frequency interval [-W,W].

The eigenvalue problem is given by

The 0-th order DPSS sequence, g0 is the eigenvector corresponding to the largest eigenvalue. The 1-st order DPSS sequence, g1 is the eigenvector corresponding to the next largest eigenvalue and is orthogonal to the 0-th order sequence. The 2-nd order DPSS sequence, g2, is the eigenvector corresponding to the third largest eigenvalue and is orthogonal to the 0-th order and 1-st order DPSS sequences. Because the operator is N-by-N, there are N eigenvectors. However, it can be shown that for a given sequence length N and a specified bandwidth [-W,W], there are approximately 2NW–1 DPSS sequences with eigenvalues very close to unity.

Multitaper Spectral Estimation

The periodogram is not a consistent estimator of the true power spectral density of a wide-sense stationary process. To produce a consistent estimate of the PSD, the multitaper method averages modified periodograms obtained using a family of mutually orthogonal tapers (windows). In addition to mutual orthogonality, the tapers also have optimal time-frequency concentration properties. Both the orthogonality and time-frequency concentration of the tapers is critical to the success of the multitaper technique. See Discrete Prolate Spheroidal (Slepian) Sequences for a brief description of the Slepian sequences used in Thomson's multitaper method.

The multitaper method uses K modified periodograms with each one obtained using a different Slepian sequence as the window. Let

denote the modified periodogram obtained with the k-th Slepian sequence, gk,n.

In the simplest form, the multitaper method simply averages the K modified periodograms to produce the multitaper PSD estimate.

Note the difference between the multitaper PSD estimate and Welch's method. Both methods reduce the variability in the periodogram by averaging over approximately uncorrelated estimates of the PSD. However, the two approaches differ in how they produce these uncorrelated PSD estimates. The multitaper method uses the entire signal in each modified periodogram. The orthogonality of the Slepian tapers decorrelates the different modified periodograms. Welch's overlapped segment averaging approach uses segments of the signal in each modified periodogram and the segmenting decorrelates the different modified periodograms.

The preceding equation corresponds to the 'unity' option in pmtm. However, as explained in Discrete Prolate Spheroidal (Slepian) Sequences, the Slepian sequences do not possess equal energy concentration in the frequency band of interest. The higher the order of the Slepian sequence, the less concentrated the sequence energy is in the band [-W,W] with the concentration given by the eigenvalue. Consequently, it can be beneficial to use the eigenvalues to weight the K modified periodograms prior to averaging. This corresponds to the 'eigen' option in pmtm.

Using the sequence eigenvalues to produce a weighted average of modified periodograms accounts for the frequency concentration properties of the Slepian sequences. However, it does not account for the interaction between the power spectral density of the random process and the frequency concentration of the Slepian sequences. Specifically, frequency regions where the random process has little power are less reliably estimated in the modified periodograms using higher order Slepian sequences. This argues for an frequency-dependent adaptive process, which accounts not only for the frequency concentration of the Slepian sequence, but also for the power distribution in the time series. This adaptive weighting corresponds to the 'adapt' option in pmtm and is the default for computing the multitaper estimate.

References

[1] Percival, D. B., and A. T. Walden, Spectral Analysis for Physical Applications: Multitaper and Conventional Univariate Techniques. Cambridge, UK: Cambridge University Press, 1993.

[2] Thomson, D. J., "Spectrum estimation and harmonic analysis." Proceedings of the IEEE®. Vol. 70, 1982, pp. 1055–1096.

See Also

| |

Was this topic helpful?