0% found this document useful (0 votes)
83 views28 pages

Random Signal Analysis & Power Spectral Density: Digital Signal Processing, © 2006 Robi Polikar, Rowan University

The document discusses random signals and their analysis. It defines random signals and processes, and introduces key concepts like autocorrelation, autocovariance, stationarity and ergodicity which are used to characterize random signals. It also discusses power spectral density and methods for estimating it from random signals.

Uploaded by

Nikita Shakya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views28 pages

Random Signal Analysis & Power Spectral Density: Digital Signal Processing, © 2006 Robi Polikar, Rowan University

The document discusses random signals and their analysis. It defines random signals and processes, and introduces key concepts like autocorrelation, autocovariance, stationarity and ergodicity which are used to characterize random signals. It also discusses power spectral density and methods for estimating it from random signals.

Uploaded by

Nikita Shakya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Lecture 24

Random Signal
Analysis &
Power Spectral
Density

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Today in DSP
 Definition & characterization of random signals
ª Autocorrelation & Auto covariance functions
ª Stationarity
ª Ergodicity
 Transform domain representation of random signals
ª Power density spectrum
 Power spectrum density estimation
ª Periodogram
ª Welch’s method

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Random Signals
 Most signals we have worked with so far are deterministic signals, so-called
because their value can be determined for any time instance n. They are given as
functions of time, using an analytical expressions, e.g. sin(2πf0n).
 Many signals in real world cannot be expressed as an analytical function of time,
and hence their values cannot be predicted ahead of time. Such signals are known as
random signals, and the process that generate them are called random processes.
ª Speech signals, radar signals, biological signals, video signals, audio signals, etc. are all
examples of random signals.
 Random signals (or processes) are usually modeled as an ensemble of signals
{X[n]}. One particular sequence {x[n]} in this collection is called a realization of
the random process.
ª At any given time index n, the observed value x[n] is the value taken by the random variable
X[n]. Thus a random process is a family of random variables, {X[n]}

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Random Process
 Consider four thermometers placed at four close-by locations, monitoring the
temperature in a plant. Each is a random signal (realization) of the random process.
Temperature, Fº

Location 1
Location 2
Location 3
Location 4

0 1 2 3 4 5 6 7 8 9 10 11 12
Time (days)
Digital Signal Processing, © 2006 Robi Polikar, Rowan University
Statistical Properties of
Random Processes
 Random signals are described by their statistical properties. For
example, the mean or expected value of {X[n]} is

μ X [ n] = E ( X [ n]) = ∫ x ⋅ p ( x )dx
−∞
ª Note that the mean value itself is a sequence: μ[n], μ[n-1], μ[n-2], …
 The mean square value of {X[n]} at time n is

(
E X [ n] 2
) = ∫ x2 ⋅ p ( x )dx
−∞

 And its variance is



σ X2 [n] = E ⎡( X − μ X ) = E ⎡{ X [n] − μ X [n]} =
⎢⎣ ⎥⎦
2⎤
⎢⎣ ⎥⎦
2⎤
∫ ( x − μX )
2
( ) 2
⋅ p ( x ) dx = E X [n]2 − [ μ X [n]]
−∞

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Autocorrelation
Function
 In analysis of random sequence, an important entity is the two-dimensional
autocorrelation sequence, which tells us how much two time instances of the
signal are correlated with each other:
φ XX [ m, n ] = E ( X [ m ] X ∗ [ n ]) or φ XX [ n, n − k ] = E ( X [ n ] X ∗ [ n − k ])
ª To understand this sequence, recall that the random process is really an ensemble
of sequences, x1[n], x2[n], …etc. Let’s fix the value of n to say n0, and obtain
x1 [ n 0 ] x1∗ [ n 0 − k ] , k = 0, ± 1, ± 2, ...
x 2 [ n 0 ] x 2∗ [ n0 − k ] , k = 0, ± 1, ± 2,...
M
ª The mean of these sequences give us φXX[no, n0-k], for a particular value of n0. By
repeating it for all values of n, we obtain the autocorrelation function
ª φXX[no, n0-k] tells us how much is the random signal at time n0 is correlated with
itself after k delayed time steps (also called lags), or more generally, φXX[m,n] tells
us how much the signal’s mth time step and nth step are correlated with each other.
When plotted as a function of lags, the autocorrelation function becomes 1-D
Digital Signal Processing, © 2006 Robi Polikar, Rowan University
Autocorrelation
Function
n=1:1000; Some random (Gaussian) signal
4
ww = randn(1000,1);
[c_ww,lags] = xcorr(ww); 2
subplot(211)
plot(n, ww); 0
grid -2
title('Some random (Gaussian) signal')
xlabel('n') -4
0 100 200 300 400 500 600 700 800 900 1000
subplot(212) n
plot(lags,c_ww) Autocorrelation sequence φ XX(n, n-Lag) of the random signal
grid
1500
title('Autocorrelation sequence
R_{XX}(n, n-Lag) of the random signal') 1000
xlabel('Lag')
500

-500
-1000 -800 -600 -400 -200 0 200 400 600 800 1000
Lag

What does this mean?


This random signal is so random that, it is only correlated with each other when
k=0, or at zero lag, or only when the signal overlaid on itself!
Digital Signal Processing, © 2006 Robi Polikar, Rowan University
Autocovariance
 A related entity is the autocovariance function. Just like the
autocorrelation function determines how much the sequence is
correlated with itself (at different lags), the autocovariance function
determines how much the sequence varies with itself.
 Technically, it is the mean-removed autocorrelation

(
γ XX [ m, n ] = E ( X [ m ] − μ X [ m ]) ( X [ n ] − μ X [ n ])

) or
= φ XX [ m, n ] − μ X [ m ] μ X [ n ]

(
γ XX [ n, n − k ] = E ( X [ n ] − μ X [ n ]) ( X [ n − k ] − μ X [ n − k ])

)

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Cross-Correlation
& Cross-Covariance
 Instead of calculating the correlation and covariance of the sequence
with shifted versions of itself, we can calculate correlation and
covariance of two difference sequences. These entities are called,
cross-correlation and cross-covariance, respectively.
φ XY [ m, n ] = E ( X [ m ]Y ∗ [ n ]) or φ XY [ n, n − k ] = E ( X [ n ]Y ∗ [ n − k ])

and

(
γ XY [ m, n ] = E ( X [ m] − μ X [ m]) (Y [ n ] − μY [ n ])

) or
= φ XY [ m, n ] − μ X [ m ] μY [ n ]

(
γ XY [ n, n − k ] = E ( X [ n ] − μ X [ n ]) (Y [ n − k ] − μY [ n − k ])

)
We will soon see that these functions become useful in analyzing the random
signals in the frequency domain
Digital Signal Processing, © 2006 Robi Polikar, Rowan University
Stationarity
 In general, all of the previously calculated sequences are functions of time, i.e., the
quantities computed (mean, variance, auto-covariance, etc.) vary in time.
 If the PDF of a random process does not change in time, such a process is called
stationary, however, strict stationarity is practically impossible for all real world
signals.
 The class of signals often encountered in DSP are so-called wide-sense-stationary
(WSS) processes, for which these quantities are either independent of time, or at
least, the time origin.
 For a WSS process:
ª X[n], the mean μX[n] is independent of time, and hence it is constant, μX
ª The autocorrelation and autocovariance functions are also independent of time, m and n,
but only dependent on the difference of time-indices, m-n. Hence they are 1-D functions of
the lag between time m and time n.
φ XX [l ] = φ XX [ n ± l , l ] = E ( X [ n + l ] X ∗ [ n ])

(
γ XX [l ] = γ XX [ n ± l , l ] = E ( X [ n + l ] − μ X ) ( X [ n ] − μ X )

)
= φ XX [l ] − μ X
2

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Special cases
 For a WSS process, the following hold:

( )
• The mean-square value of a WSS process is its
φ XX [ 0] = E ( X [ n ] X [ n ]) = E X [ n ]
∗ 2
autocorrelation function evaluated at zero lag!

σ X2 = γ XX [0] = φ XX [ 0] − μ X
2 • The variance of a WSS process is its
auto-covariance evaluated at zero lag!

 We can show that the following symmetry properties are also valid
φ XX [ −l ] = φ XX

[l ] These functions, the autocorrelation, auto-covariance,
cross correlation and cross covariance, are all two-sided sequences
γ XX [ −l ] = γ XX

[l ] with conjugate symmetry.
φ XY [ −l ] = φ XY

[l ]
If the original process is purely real, then the conjugation can also
γ XY [ −l ] = γ XY

[l ] be dropped.

φ XX [ 0]φYY [ 0] ≥ φ XY [l ]
2

γ XX [ 0] γ YY [ 0] ≥ γ XY [l ]
2

φ XX [ 0] ≥ φ XX [l ]
Both the autocorrelation and auto covariance functions assume
their maximum values at zero lag. This should make sense, why?
γ XX [ 0] ≥ γ XX [l ]
Digital Signal Processing, © 2006 Robi Polikar, Rowan University
Ergodicity
 First recall: A random signal x[n] is really one of an ensemble of signals that are generated by
a random process. Every time we generate x[n], we in fact get a different realization.
 If the statistical properties of these different realizations are not different, then such a random
processes is said to be stationary. In such a case, the probability distribution function of the
random process is independent of time.
ª This is a very restrictive property, not generally satisfied.
ª Leaving the mean independent of time, if we require that the correlation and covariance functions be
dependent only on the time-difference (lag), then we have wide-sense stationarity.
 Now, notice that we normally do not have access to all realizations, but rather just one. If
each realization behaves exactly as the ensemble, in other words, if we can obtain the
statistical behaviors of the ensemble from just one single realization, such processes are
called ergodic processes. Notice that only (wide sense) stationary signals can be ergodic.
 More formally, a (WS) stationary random signal is said to be ergodic, if all of its statistical
properties can be estimated from a single realization of a sufficiently large finite length.

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Ergodicity
 For ergodic signals, then 1 M
μ X [ n ] = μ X = lim ∑ x [ n]
M →∞ 2 M + 1
n =− M

1 M
σ X [ n ] = σ X = lim ∑ ( [ ] )
2
2 2
x n − μ
M →∞ 2 M + 1
X
n =− M

1 M
φ XX [l ] = lim
M →∞ 2 M + 1
∑ ( x [ n ] x [ n − l ])
n =− M

1 M
γ XX [l ] = lim
M →∞ 2 M + 1
∑ ( x [ n] − μ X ) ( x [ n − l ] − μ X )
n =− M

 Of course, since we also have access to a finite observation only, we would have to get rid of
the limits, and calculate the above quantities for the duration of the signal available. In such a
case, we only calculate their unbiased estimates.

1 M 1 M
μˆ X [ n ] = μˆ X = ∑ x [ n] φXX [l ] = M + 1 ∑
M + 1 n =0
ˆ ( x [ n ] x [ n − l ])
n=0

1 M 1 M
σ X [ n] = σ X = ∑ ( x [ n] − μ X ) γ XX [l ] = M + 1 ∑ ( x [ n] − μ X ) ( x [ n − l ] − μ X )
2 2 2
ˆ ˆ ˆ
M + 1 n =0 n=0

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Frequency Domain Representation of
Random Processes

 Now, suppose we would like to obtain the frequency domain


representation of a random process
ª For example, we have a noise source, and we would like to find out the frequency
spectrum of this noise generating process.
ª If x[n] is the noise signal generated by this process,

we might compute its DTFT to
obtain X(ω), the spectrum of x[n] X (ω ) = ∑ x[n] e − jω n
n =−∞
ª And we would bedead-wrong!
dead-wrong!
 Here is why: In fact there are – not one – but two reasons:
ª First, X(ω) is really the DTFT of a specific realization of X, which is x[n]. For each
different realization of x[n] we would get a different spectrum – yet we are
interested in the spectrum of the overall process.
ª Second, random signals are, by the very nature of their definition, infinitely long in
time. Therefore, they generally do not satisfy the Dirichlet conditions, and their
DTFT is not defined in the first place.

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


So…? What to do…?
 While the random signals themselves usually do not have a DTFT,
their autocorrelation and autocovariance sequences do!
ª This is – inpart – because they are usually monotonically decreasing from their
maximum value at lag=0, and hence the infinite Fourier sum is then absolutely
summable.
ª Specifically, the DTFT of the autocorrelation function of a WSS sequence X[n] can
be computed as:

S XX (ω ) = S X (ω ) = Φ XX (ω ) = ∑ φ [l ] e
l =−∞
XX
− jωl

which turns out to be the power spectrum of the original random process, which
is known as the Wiener – Khintchine theorem. If SXX(ω) is normalized by 2π, the
quantity obtained is known as the power density spectrum or power spectral
density (PSD), PXX(ω), although SXX(ω) is also routinely referred to as the PSD as
well. Both functions – due to symmetry of φXX – are guaranteed to be real.
ª Furthermore, the average power of a WSS random signal is computed as

(
PX = E X [ n ]
2
) =φ XX [ 0] =
2
μ X + σ X2

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Understanding
Power Spectral Density
 Now let’s look at this expression again:
(
PX = E X [ n ]
2
) =φ XX [ 0] =
2
μ X + σ X2

 Considering that the autocorrelation function is the inverse DTFT


π
1 PXX (ω ) = S XX (ω ) 2π
φ XX [l ] = ∫π S XX (ω ) e jωl d ω
2π −

ª Then,
( )
π π
1 1
PX = E X [ n ] = φ XX [ 0] = ∫π S (ω ) e ∫π S (ω ) dω
2 jω 0
dω =
2π 2π
XX XX
− −

That is, the average power is the PSD, integrated (averaged) over all frequencies.
If we wanted to find the average power in a particular frequency band, say [ω1 ω2], then
ω2 −ω1

P[ω1 ω2 ] = ∫ω P (ω ) dω + ∫ω
XX

PXX (ω ) d ω
1 2

Hence, PXX(ω) is not the power at frequency ω, but rather the power density, in an
infinitesimal frequency band around ω, or in other words, it is the power per unit frequency
band. To obtain the actual average power in any frequency band, we simply integrate the
power density in that interval.

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Estimating PSD
 There is still one more problem, however:
ª While the definition of the PSD as the DTFT of the autocorrelation function allows us to
formally define PSD, it is still incomputable using a computer. This is because – not only
because DTFT is continuous (that we can handle, by computing the DFT instead) - but also
because the autocorrelation is still infinitely long.
 So how to we calculate the PSD?
ª The easiest approach is to
• Truncate the autocorrelation function
• Compute the DFT
ª This is really an approximation to the PSD, known as the periodogram method for PSD
estimation, since the autocorrelation function is truncated,
• Note that the truncation can be considered as being multiplied by a rectangular window function,
which we know introduces the Gibbs’s effect.
• Over the years, many PSD estimation methods have been developed to mitigate some of the
negative effects of the PSD estimation through the periodogram.
• For most practical purposes, and at least for the purposes of this class, periodogram method is
sufficient.

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


The Periodogram
 The periodogram estimate of the PSD of a finite length-L sequence x[n] is
S (ω ) 1
DFTN ( x [ n ])
2
PˆXX (ω ) = XX = Where N is typically chosen as the next power of 2
2π N value greater than L
1
DFTN ( x [ n ])
2
PˆXX ( f ) =
fs N

 In Matlab, the function periodogram() implements the above expressions

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Periodogram in
Matlab
periodogram Power Spectral Density (PSD) estimate via periodogram method.

Pxx = PERIODOGRAM(X) returns the PSD estimate of the signal specified by vector X in the vector Pxx. By default, the
signal X is windowed with a BOXCAR window of the same length as X. The PSD estimate is computed using an FFT
of length given by the larger of 256 and the next power of 2 greater than the length of X. Pxx is the distribution of
power per unit frequency. For real signals, PERIODOGRAM returns the one sided PSD by default; for complex
signals, it returns the two-sided PSD. Note that a one-sided PSD contains the total power of the input signal.

Pxx = PERIODOGRAM(X,WINDOW) specifies a window to be applied to X.WINDOW must be a vector of the same
length as X. If WINDOW is a window other than a boxcar (rectangular), the resulting estimate is a modified
periodogram. If WINDOW is specified as empty, the default window is used.

[Pxx,W] = PERIODOGRAM(X,WINDOW,NFFT) specifies the number of FFT points used to calculate the PSD estimate.
For real X, Pxx has length (NFFT/2+1) if NFFT is even, and (NFFT+1)/2 if NFFT is odd. Note that if NFFT is greater
than the segment the data is zero-padded. If NFFT is less than the segment, the segment is "wrapped" (using
DATAWRAP) to make the length equal to NFFT. This produces the correct FFT when NFFT < L, L being signal or
segment length. W is the vector of normalized frequencies at which the PSD is estimated. W has units of rad/sample.

[Pxx,F] = PERIODOGRAM(X,WINDOW,NFFT,Fs) returns a PSD computed as a function of physical frequency (Hz). Fs is


the sampling frequency specified in Hz. If Fs is empty, it defaults to 1 Hz. F is the vector of frequencies at which the
PSD is estimated and has units of Hz.

[...] = PERIODOGRAM(...,'twosided') returns a two-sided PSD of a real signal X. In this case, Pxx will have length NFFT
and will be computed over the interval [0,2*Pi) if Fs is not specified and over the interval [0,Fs) if Fs is specified.

PERIODOGRAM(...) with no output arguments by default plots the PSD estimate in dB per unit frequency in the current
figure window.

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


An example

Periodogram estimate of the PSD


50
fs=1000;
t=(0:fs)/fs;

ff=[150];
x=sin(2*pi*ff*t); Spectral leaks due to windowing effect of the

Power/frequency (dB/Hz)
0 truncation. Side lobes are created by the
rectangular window.
[Pxx f]=periodogram(x, [], 'twosided', 1024, fs);

plot(f, 10*log10(Pxx)); %Gain in power is calculated with


10*log10(P)
grid
title('Periodogram estimate of the PSD') -50
xlabel('Frequency, Hz')
ylabel('Power/frequency (dB/Hz)')

-100
0 100 200 300 400 500 600 700 800 900 1000
Frequency, Hz

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Spectral Leaks &
Resolution
 The spectral leaks are the sidelobes created in the PSD due to the
rectangular function used in truncating the signal
ª Recall that multiplying with a rectangular function in the time domain is equivalent
to the convolution with a sinc in the frequency domain, which creates the
sidelobes.
 A side effect of the spectral leaks is the resolution – the ability to
discriminate spectral components that are located close to each other.
ª In order to resolve to frequencies that are close to each other, those frequencies
must at least be further apart from each other than the width of the mainlobe of
the leaked spectra for either of the spectra.
ª The main lobe width is defined as the width where thepower is half the peak
power of the main lobe (3dB), which is approximately fs/L
ª Hence, in order to resolve two frequencies f1 and f2, they must satisfy
fs
Δf = f1 − f 2 > e.g., two resolve two frequencies 10 Hz apart,
we need at least 100 samples at 1KHz.
L
Digital Signal Processing, © 2006 Robi Polikar, Rowan University
Another Example

Periodogram estimate of the PSD


clear 0
close all
-10
fs=1000;
t=(0:fs)/fs;
A=[1 2]; -20

Power/frequency (dB/Hz)
ff=[150; 200];
xn=A*sin(2*pi*ff*t)+0.1*randn(size(t)); -30

%Equivalent to -40
% xn=sin(2*pi*150*t)+2*sin(2*pi*140*t)
% + 0.1*randn(size(t));
-50
[Pxx f]=periodogram(xn, [], 'twosided', 1024, fs);
plot(f, 10*log10(Pxx)); -60
%Gain in power is calculated with 10*log10(P)
grid
-70
title('Periodogram estimate of the PSD')
xlabel('Frequency, Hz')
ylabel('Power/frequency (dB/Hz)') -80
0 100 200 300 400 500 600 700 800 900 1000
Frequency, Hz

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Periodogram estimate of the PSD
0

-10
fs=1000; L=100 -20
%t=(0:fs)/fs; -30

Power/frequency (dB/Hz)
L=input('Enter the signal length:');
-40
t=linspace(0, L/fs, L);
-50
A=[1 2];
-60
ff=[150; 160];
-70
xn=A*sin(2*pi*ff*t)+0.1*randn(size(t));
-80

%Equivalent to -90

% xn=sin(2*pi*150*t)+2*sin(2*pi*140*t) + -100
0 50 100 150 200 250 300 350 400 450 500
.1*randn(size(t)); Frequency, Hz

Periodogram estimate of the PSD


[Pxx f]=periodogram(xn, [], 1024, fs); 0

L=80 -10

plot(f, 10*log10(Pxx)); %Gain in power is -20

calculated with 10*log10(P) -30

Power/frequency (dB/Hz)
axis([0 500 -100 0]) -40
grid
-50
title('Periodogram estimate of the PSD')
-60
xlabel('Frequency, Hz')
-70
ylabel('Power/frequency (dB/Hz)')
-80

Ave_pow=fs/length(Pxx)*sum(Pxx) -90

-100
See what happens if you increase noise! 0 50 100 150 200 250 300
Frequency, Hz
350 400 450 500

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Modified Periodogram
 We can, of course, use a different windowing function than the
rectangular window (boxcar), to smooth the edges of the truncation.
This reduces the spurious frequencies introduced through leakage.
ª On the other hand, all other windows have a wider mainlobe, which means that
the resolution is then reduced.
• For Hamming window, for example, the 3dB width is twice that of the boxcar function,
and hence only half the resolution can be obtained with the same signal length
compared to boxcar function.
• Try implementing periodogram(xn, hamming(length(xn)), 1024, fs);
ª Using different window functions is known as the modified periodogram
method.

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Welch’s Method
 A better estimate of the true PSD can be obtained using the following approach:
ª Divide the time-series data into (possibly overlapping) segments
ª Compute the modified periodogram of each segment
ª Average the PSD estimates obtained by each periodogram
 This is known as the Welch’s method
ª The effect is decreased variance (from one realization to the next), hence a better estimate
ª However, the reduced data length also reduces the resolution
 In Matlab, the Welch’s method is implemented by the pwelch() function.

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Welch’s Method
pwelch Power Spectral Density estimate via Welch's method.

Pxx = PWELCH(X) returns the Power Spectral Density (PSD) estimate, Pxx, of a discrete-time signal vector X using Welch's averaged, modified
periodogram method. By default, X is divided into eight sections with 50% overlap, each section is windowed with a Hamming window
and eight modified periodograms are computed and averaged. If the length of X is such that it cannot be divided exactly into eight sections
with 50% overlap, X will be truncated accordingly.

Pxx = PWELCH(X,WINDOW), when WINDOW is a vector, divides X into overlapping sections of length equal to the length of WINDOW, and
then windows each section with the vector specified in WINDOW. If WINDOW is an integer, X is divided into sections of length equal to
that integer value, and a Hamming window of equal length is used. If WINDOW is omitted or specified as empty, a default window is used
to obtain eight sections of X.

Pxx = PWELCH(X,WINDOW,NOVERLAP) uses NOVERLAP samples of overlap from section to section. NOVERLAP must be an integer
smaller than the WINDOW if WINDOW is an integer. NOVERLAP must be an integer smaller than the length of WINDOW if WINDOW
is a vector. If NOVERLAP is omitted or specified as empty, the default value is used to obtain a 50% overlap.

[Pxx,W] = PWELCH(X,WINDOW,NOVERLAP,NFFT) specifies the number of FFT points used to calculate the PSD estimate. If NFFT is
specified as empty, the default NFFT -the maximum of 256 or the next power of two greater than the length of each section of X- is used.
Note that if NFFT is greater than the segment the data is zero-padded. If NFFT is less than the segment, the segment is "wrapped" (using
DATAWRAP) to make the length equal to NFFT. This produces the correct FFT when NFFT < L, L being signal or segment length. W is
the vector of normalized frequencies at which the PSD is estimated. W has units of rad/sample.

[Pxx,F] = PWELCH(X,WINDOW,NOVERLAP,NFFT,Fs) returns a PSD computed as a function of physical frequency (Hz). Fs is the sampling
frequency specified in Hz. If Fs is empty, it defaults to 1 Hz. F is the vector of frequencies at which the PSD is estimated and has units of
Hz. For real signals, F spans the interval [0,Fs/2] when NFFT is even and [0,Fs/2) when NFFT is odd. For complex signals, F always spans
the interval [0,Fs).

[...] = PWELCH(...,'twosided') returns a two-sided PSD of a real signal X. In this case, Pxx will have length NFFT and will be computed over the
interval [0,2*Pi) if Fs is not specified and over the interval [0,Fs) if Fs is specified. Alternatively, the string 'twosided' can be replaced with
the string 'onesided' for a real signal X. This would result in the default behavior. The string 'twosided' or 'onesided‘ may be placed in
any position in the input argument list after NOVERLAP.

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Example
fs=1000;
%t=(0:fs)/fs;
L=input('Enter the signal length:');
Periodogram estimate of the PSD
t=linspace(0, L/fs, L); 20

Power/frequency (dB/Hz)
A=[2 8];
ff=[150; 160]; 0
xn=A*sin(2*pi*ff*t)+5*randn(size(t));
-20

[Pxx1 f]=periodogram(xn, rectwin(length(xn)), -40


1024, fs);
[Pxx2 f]=pwelch(xn, rectwin(150),75, 1024, -60
fs); %For 300 points, this is 3 segments of 0 50 100 150 200 250 300 350 400 450 500
Frequency, Hz
50% overlap
Welch estimate of the PSD
10
Power/frequency (dB/Hz)
subplot(211)
plot(f, 10*log10(Pxx1)); grid 0
title('Periodogram estimate of the PSD')
xlabel('Frequency, Hz') -10
ylabel('Power/frequency (dB/Hz)')
-20

subplot(212) -30
plot(f, 10*log10(Pxx2)); grid 0 50 100 150 200 250 300 350 400 450 500
Frequency, Hz
title('Welch estimate of the PSD')
xlabel('Frequency, Hz')
ylabel('Power/frequency (dB/Hz)')

Digital Signal Processing, © 2006 Robi Polikar, Rowan University


Friday
 Dr. Polikar will be out of town.
 You will be given a survey (similar to the one you took in Freshman
year)
 There will be a graduate student who will distribute the lab protocol
for Friday. The lab protocol for this week will NOT be available on
the web page. Please make sure that you come to class on Friday.

Digital Signal Processing, © 2006 Robi Polikar, Rowan University

You might also like