You are on page 1of 7

Power Spectral Density - the basics

Power Spectral Densfty (PSD) is the frequency response of a random or periodic signal. It tells
us where the average power is distributed as a function of frequency.

The PSD is deterministic, and for certain types of random signals is independent of time1.
This is useful because the Fourier transform of a random time signal is itself random, and
therefore of little use calculating transfer relationships (i.e., finding the output of a filter
when the input is random).

The PSD of a random time signal x(t) can be expressed in one of two ways that are
equivalent to each other
1. The PSD is the average of the Fourier transform magnitude squared, over a large
time interval
1
S x ( f ) lim E
T 2T

x(t )e
T

j 2ft

dt

2. The PSD is the Fourier transform of the auto-correlation function.


Sx ( f )

R ( )e
T

j 2ft

dt

R x ( ) E x(t ) x * (t )

The power can be calculated from a random signal over a given band of frequencies as
follows:

1. Total Power in x(t):

2. Power in x(t) in range f1 - f2:


1

S ( f )df R (0)

P12

f2

S ( f )df R (0)
f1

The signal has to be stationary, which means that us statistics do not change as a function of
time.

If a random signal x(t) is passed through a time-invariant filter with frequency response H(f),
the resulting signal y(t) has a PSD as follows:

x(t)

y(t)

H(f)

Sy ( f ) Sx ( f ) H( f )

Example: Random Gaussian noise signals.


Two random signals x1(t) and x2(t) of 10 seconds duration are created as follows:

xl=randn(1,10000);
x2=randn(1,10000);
t=linspace(0,10,10000);
dt = t(2)-t(1);
subplot(2,2,1),plot(t,x1)
subplot(2,2,2),plot(t,x2)

% signal 1
% signal 2
% time series
% time increment
%plot of x1
%plot of x2

The sample frequency is 1kHz. The FFT of each of these signals is calculated from

X1=fftshift(fft(x1));
X2=fftshift(fft(x2));
Df=1/dt;
f=linspace(Df/2,Df/2,10000);
subplot(2,2,3),plot(f,dB(X1));
subplot(2,2,4),plot(f,dB(X2));

% FFT of signal 1
% FFT of signal 2
% fequency span
% frequency series
%plot of FFT of x1
%plot FFT of x2

The plot below shows a 0.1 second snapshot of two random time functions x1(t) and x2(t) and
the first 10 Hz of the fast Fourier transform of these signals.
This shows that the frequency responses of these random signals are generally different,
although they seem to have a common average level, and have similar overall randomness,
which would be exhibited in the rest of the spectrum if we were to show it.
Perhaps what we should be doing is looking at the average Fourier transform instead of just a
single sample of the Fourier transform this is, more or less, what the PSD is; it is the average
Fourier transform squared taken over a very long time interval.

We now calculate and plot the PSD of the original time series x1(t) and x2(t).
x1=randn(1,10000);
x2=randn(1,10000);
t=linspace(0,10,10000);
dt = t(2)-t(1);
Df = 1/dt
subplot(2,2,1),plot(t,x1)
subplot(2,2,2),plot(t,x2)
Sx1=psd(x1,1024,1000);
Sx2=psd(x2,1024,1000);
f=linspace0,Df/2,length(Sx1));
subplot(2,2,3),plot(f,db(Sx1));
subplot(2,2,4),plot(f,db(Sx2));

% signal 1
% signal 2
% time series
% time increment
% fequency span
%plot of x1
%plot of x2
%PSD of x1
%PSD of x2
% frequency series
%plot of PSD of x1
%plot of PSD of x2

The PSD for each signal looks more or less flat across the frequency band. This type of noise is
referred to as white, and if we had taken an infinitesimally small time increment, we would see
this flatness across the entire frequency band.
The reason that there is some variation about the constant level is that we didnt take a large
enough (i.e., infinite) time sequence of random numbers to calculate the PSD from. The estimate
of the PSD (as calculated in MATLAB) becomes more accurate as the sample size becomes
infinite.
The mean of the PSDs of xl and x2 turn out to be very close to 1.
mean(Sxl)
mean(Sx2)

%= 1.0137
%= 1.0241

This is telling us that the average value of the MATLAB PSD, which is the variance, is close to
unity.
Now lets consider filtering the Gaussian noise. First design a high order Butterworth filter that
cuts off at half the Nyquist frequency (500 Hz)
[b,a]=butter(40,0.5);

%n=40th order,fc=0.5 nyquist

Now plot the frequency response, normalized to the nyquist frequency (this just makes the
maximum frequency be 1)
freqz(b,a)

% plot the frequency and phase response

Now produce new noise samples y1(t) and y2(t) by filtering x1(t) and x2(t).

y1=filter(b,a,x1);
%filter x1
y2=filter(b,a,x2);
%filter x2
Y1=fftshift(fft(y1)); %calculate frequency response of y1
Y2=fftshift(fft(y2)); %calculate frequency response of y2
subplot(2,2,1),plot(t,x1)
%plot of y1
subplot(2,2,2),plot(t,x2)
%plot of y2
subplot(2,2,3),plot(f,dB(X1));
%plot of FFT of y1
subplot(2,2,4),plot(f,dB(X2));
%plot FFT of y2

We see that the time series is smoother (it has been filtered), but the FFT remains random. The
variance of the filtered noise is reduced to roughly 0.5.

var(y1)
var(y2)

%= 0.4895
%= 0.4956

Taking the PSD of the filtered noise

Sy1=psd(y1,1024,1000);
Sy2=psd(y2,1024,1000);
f=linspace(0,Df/2,length(Sx1));
subplot(2,2,1),plot(t,x1)
subplot(2,2,2),plot(t,x2)
subplot(2,2,3),plot(f,db(Sy1));
subplot(2,2,4),plot(f,db(Sy2));

%PSD of y1
%PSD of y2
% frequency series
%plot of y1
%plot of y2
%plot of PSD of x1
%plot of PSD of x2

Basically what we have done here is filtered white noise. The PSD of the filtered noise takes on
the shape of the filter frequency response, and is the same (within experimental variation) for
each independent noise signal.

Calculating the variance of the filtered noise results in


mean(Syl) %= 0.4851
mean(Sy2) %= 0.4910
The means are both close to 0.5. Not surprisingly, cutting out half the noise with a steep high
order Butterworth filter has reduced the total variance by approximately 0.5. The variance for a
flat PSD with amplitude Sx (W/Hz) and total positive and negative frequency extent f is found
by (x)2 = Sxf.
In MATLABs calculation of PSD, f is normalized to 1, so (x)2 = Sy= 1. For the filtered signal,
Sx is 1 for half of f and 0 for the other half of f, so (x)2 = Sy/2= 1/2. In general, when the
PSD is not simple shaped as in the above examples, you will need to integrate the PSD in order
to find the variance. In MATLAB, this is equivalent to simply finding the mean of the PSD.
What can you conclude about the PSD and white Gaussian Noise?

You might also like