# Power spectral density vs. Fourier Transform

I am trying to understand the difference between the Power Spectral Density and the Fourier transform. Specifically, I am trying to understand why the power spectral density is useful and in what scenarios it is useful.

For example, suppose I have some time series and I want to get a better understanding of the frequency content of the time series. I can either take the Fourier transform (e.g. FFT), or I can compute the power spectral density. The power spectral density involves windowing, computing the autopowers for each window and summing. It seems to involve many more steps than a straight-forward FFT.

Below is a MATLAB script I wrote to examine this;

T = 1; %Length of time series in seconds
Fs = 1000; %sample frequency
dt = 1/Fs; %sample length
N = T/dt; %Number of time samples
t = (0:N-1)*dt; %Time vector
f = (0:N/2)*Fs/N; %Frequency vector

%Frequency content of the signal (three frequencies in Hz)
F1 = 200;  F2 = 400;  F3 = 350;
sigma = 3; %Standard deviation of the noise to be added

%Create time series
r = sin(2*pi*F1*t)+sin(2*pi*F2*t)+sin(2*pi*F3*t)+sigma*randn(1,N); %Time series

%Compute one-sided FFT
R = fft(r); %Fourier transform of time series
R2 = abs(R/N);
R1 = R2(1:N/2+1);
R1(2:end-1) = 2*R1(2:end-1);

%Compute power spectral density (autospectrum)
[pxx,fxx] = cpsd(r,r,bartlett(256),128,2048,Fs);

%Plot results
subplot(3,1,1)
plot(t,r,'-'); %Time Series
title('Time series');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(3,1,2)
plot(f,R1,'-') %One-sided FFT amplitude spectrum
title('Fourier transform');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
axis([0 Fs/2 0 1.1])

subplot(3,1,3)
plot(fxx,2*pi*pxx) %Autospectrum
title('Power Spectral Density')
xlabel('Frequency (Hz)')
ylabel('Power / Hz')


The output from this script is the following figure:

Both the FFT spectrum and the autopower spectrum show peaks at 200, 350, and 400 Hz which is good because that is what the true signal contains. But the peaks are more obvious in the FFT. So why would I use the power spectral density method?

Can anyone provide a simple example where the FFT fails to show the correct spectrum but the autopower is able to recover it?

• What you might be missing is that many power spectral density methods assume that your samples are one realization of an underlying random process, and they try to estimate the PSD of the process itself using the available samples.
– MBaz
Jan 29, 2020 at 22:03
• Thanks for the comment. How would I create a time series containing "samples ... of an underlying random process"? I will also add this as a new question as I think you have focused in on my main issue. Jan 30, 2020 at 17:00
• Well, as an example consider randn(), a function that returns a sample from an (underlying) Gaussian process. Or, sample a noisy signal using an ADC.
– MBaz
Jan 30, 2020 at 22:10
• The spectra of randn will be white though, won't it? I want to get a PSD that has specific peaks in the spectra (e.g. at 200, 350, and 400 Hz). The other suggestion (using an ADC) won't work in my case since my synthetic signal is digital (i.e. I want to create the signal from scratch in MATLAB). Could I re-sample a noisy digital signal at a different sampling rate? Jan 31, 2020 at 1:43
• You're right, of course; I was trying to answer your more general question, "how to create samples of an underlying random process". I've posted an answer to your other question.
– MBaz
Jan 31, 2020 at 19:58