Time series from Power Spectral Density (PSD)

조회 수: 94 (최근 30일)
Albert Zurita
Albert Zurita 2023년 6월 2일
댓글: William Rose 2024년 10월 30일
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')

채택된 답변

William Rose
William Rose 2023년 6월 3일
@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
Paul
Paul 2024년 10월 30일
편집: Paul 2024년 10월 30일
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 2024년 10월 30일
@Paul, Well said and very nicely illustrated!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Parametric Spectral Estimation에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by