Time series from Power Spectral Density (PSD)

94 views (last 30 days)
Hi, I would like to compute different time series (time realizations) of a given PSD. I've read there are several methods using random phase and amplitude or going through an IFFT. Is there any method already built in Matlab or how should this be done? I paste here below an example of a PSD. Thanks!
f = [6.5e-4 5.8e-2 5];
PSD = [1e2 1e-2 1e-6];
coef = polyfit(log10(f),log10(PSD),1);
f2 = linspace(0.8*1e-4,20,1000);
PSD2 = 10.^(polyval(coef,log10(f2)));
loglog(f2,PSD2);grid on;
xlabel('Hz');ylabel('m^2/Hz')

Accepted Answer

William Rose
William Rose on 3 Jun 2023
@Albert Zurita, you wrote:
I would like to compute different time series (time realizations) of a given PSD. I've read there are several methods using random phase and amplitude or going through an IFFT.
You are partly correct. If you know the PSD you can compute the amplitude spectrum. You can use phases that are all zero, or that are random, or whatever you choose. Then you can compute th inverse FFT.
I assume the time sequence is to be a real sequence, not complex. If so, then the phase angle ust be zero or pi/2 at the Nyquist frequency (fNyq) (assuming an even number of samples; if the number is odd, then the Nyquist frequency will not be sampled...), and all complex components of hte spectrum above fNyq must be the complex conjugates of their "mirror images" below fNyq.
If you follow these guidelines then the ifft of the complex spectrum will yield a real sequence, as you probably desire.
  22 Comments
Paul
Paul on 30 Oct 2024
Edited: Paul on 30 Oct 2024
The reason why I'm amazed by Parseval's relationship for the DFT is based on a visualization of the quantities inolved.
Define a finite duration signal of length 20
rng(101);
N = 20;
n = 0:N-1;
x = rand(N,1); x = x - mean(x)*0.6;
Its DFT
Xdft = fftshift(fft(x));
wdft = (-N/2:(N/2-1))/N*2*pi;
Its DTFT
XDTFT = @(w) freqz(x,1,w);
wDTFT = linspace(-1,1,2048)*pi;
Overlay the abs(DFT)^2 on the abs(DTFT)^2
figure
plot(wDTFT,abs(XDTFT(wDTFT)).^2,'LineWidth',2);
hold on
plot(wdft,abs(Xdft).^2,'o');
Add the rectangles of height abs(DFT)^2 and width dw = 2*pi/N (rad/sample)
bar(wdft,abs(Xdft).^2,1,'FaceAlpha',0.5);
xlabel('\omega (rad/sample)')
The amazing thing to me is that the area under the DTFT curve is the same as the area under the DFT rectangles. To me, at least, that is a very unexpected result by just looking at the plot. And there is some funny business at the edges where the left most rectangle extends to less than -pi and the right most rectangle stops before pi, and becasue N is even we have he unpaired point on the far left. Nevertheless, we have
[integral(@(w) abs(XDTFT(w)).^2,-pi,pi), 2*pi/N*sum(abs(Xdft).^2)]
ans = 1×2
14.7415 14.7415
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
which is, of course, 2*pi*E(x[n]), where E(x[n]) is the energy in x[n], exactly as Parseval tells us.
sum(abs(x).^2)*2*pi
ans = 14.7415
Intuitively, I can see why the DTFT works the way it does wrt to E(x[n]), but the DFT is another story for me. Normally, the rectangular method is an approximation to an integral, but here it is exact, despite apparent visual appearances to the contrary.
William Rose
William Rose on 30 Oct 2024
@Paul, Well said and very nicely illustrated!

Sign in to comment.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!