pmcov

Autoregressive power spectral density estimate — modified covariance method

Syntax

  • pxx = pmcov(x,order)
  • pxx = pmcov(x,order,nfft)
  • [pxx,w] = pmcov(___)
  • [pxx,f] = pmcov(___,fs) example
  • [pxx,w] = pmcov(x,order,w)
  • [pxx,f] = pmcov(x,order,f,fs)
  • [___] = pmcov(x,order,___,freqrange)
  • [___,pxxc] = pmcov(___,'ConfidenceLevel',probability)

Description

pxx = pmcov(x,order) returns the power spectral density estimate, pxx, of a discrete-time signal, x, found using the modified covariance method. When x is a vector, it is treated as a single channel. When x is a matrix, the PSD is computed independently for each column and stored in the corresponding column of pxx. pxx is the distribution of power per unit frequency. The frequency is expressed in units of rad/sample. order is the order of the autoregressive (AR) model used to produce the PSD estimate.

pxx = pmcov(x,order,nfft) uses nfft points in the discrete Fourier transform (DFT). For real x, pxx has length (nfft/2+1) if nfft is even, and (nfft+1)/2 if nfft is odd. For complex–valued x, pxx always has length nfft. pmcov uses a default DFT length of 256.

[pxx,w] = pmcov(___) returns the vector of normalized angular frequencies, w, at which the PSD is estimated. w has units of radians/sample. For real–valued signals, w spans the interval [0,π] when nfft is even and [0,π) when nfft is odd. For complex–valued signals, w always spans the interval [0,2π).

example

[pxx,f] = pmcov(___,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] = pmcov(x,order,w) returns the two-sided AR PSD estimates at the normalized frequencies specified in the vector, w. The vector, w, must contain at least 2 elements.

[pxx,f] = pmcov(x,order,f,fs) returns the two-sided AR 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/s (Hz).

[___] = pmcov(x,order,___,freqrange) returns the AR PSD estimate over the frequency range specified by freqrange. Valid options for freqrange are: 'onesided', 'twosided', or 'centered'.

[___,pxxc] = pmcov(___,'ConfidenceLevel',probability) returns the probability × 100% confidence intervals for the PSD estimate in pxxc.

example

pmcov(___) with no output arguments plots the AR PSD estimate in dB per unit frequency in the current figure window.

Examples

expand all

Modified-Covariance PSD Estimate of AR(4) Process

Create a realization of an AR(4) wide-sense stationary random process. Estimate the PSD using the modified covariance method. Compare the PSD estimate based on a single realization to the true PSD of the random process.

Create an AR(4) system function. Obtain the frequency response and plot the PSD of the system.

A = [1 -2.7607 3.8106 -2.6535 0.9238];
[H,F] = freqz(1,A,[],1);
plot(F,20*log10(abs(H)))

xlabel('Frequency (Hz)')
ylabel('PSD (dB/Hz)')

Create a realization of the AR(4) random process. Set the random number generator to the default settings for reproducible results. The realization is 1000 samples in length. Assume a sampling frequency of 1 Hz. Use pmcov to estimate the PSD for a 4th-order process. Compare the PSD estimate with the true PSD.

rng default

x = randn(1000,1);
y = filter(1,A,x);
[Pxx,F] = pmcov(y,4,1024,1);

hold on
plot(F,10*log10(Pxx))
legend('True Power Spectral Density','pmcov PSD Estimate')

Modified-Covariance PSD Estimate of a Multichannel Signal

Create a multichannel signal consisting of three sinusoids in additive $N(0,1)$ white Gaussian noise. The sinusoids' frequencies are 100 Hz, 200 Hz, and 300 Hz. The sampling frequency is 1 kHz, and the signal has a duration of 1 s.

Fs = 1000;

t = 0:1/Fs:1-1/Fs;

f = [100;200;300];

x = cos(2*pi*f*t)'+randn(length(t),3);

Estimate the PSD of the signal using the modified covariance method with a 12th-order autoregressive model. Use the default DFT length. Plot the estimate.

morder = 12;

pmcov(x,morder,[],Fs)

Input Arguments

expand all

x — Input signalvector | matrix

Input signal, specified as a row or column vector, or as a matrix. If x is a matrix, then its columns are treated as independent channels.

Example: cos(pi/4*(0:159))+randn(1,160) is a single-channel row-vector signal.

Example: cos(pi./[4;2]*(0:159))'+randn(160,2) is a two-channel signal.

Data Types: single | double
Complex Number Support: Yes

order — Order of autoregressive modelpositive integer

Order of the autoregressive model, specified as a positive integer.

Data Types: double

nfft — Number of DFT points256 (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

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 probability × 100% interval estimate for the true PSD.

Output Arguments

expand all

pxx — PSD estimatevector | matrix

PSD estimate, specified as a real-valued, nonnegative column vector or matrix. Each column of pxx is the PSD estimate of the corresponding column of x. 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 Ω and specify the sampling frequency in hertz, the PSD estimate is in watts per hertz.

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 a matrix with real-valued elements. The row size of the matrix is equal to the length of the PSD estimate, pxx. pxxc has twice as many columns as pxx. Odd-numbered columns contain the lower bounds of the confidence intervals, and even-numbered columns contain the upper bounds. Thus, pxxc(m,2*n-1) is the lower confidence bound and pxxc(m,2*n) is the upper confidence bound corresponding to the estimate pxx(m,n). The coverage probability of the confidence intervals is determined by the value of the probability input.

Data Types: single | double

See Also

| |

Was this topic helpful?