パワー スペクトル密度 P(f) を計算している場合、元の信号 x(t) がどのようにサンプリングされるかは問題ではありません。両方のスペクトルを直接かつ定量的に比較できます。スペクトル密度を計算したことを確認するには、Parsevals の定理を明示的に確認できます。
$ \int P(f) df = \int x(t)^2 dt $
もちろん、どの周波数が実際に評価されるかを考える必要があります fft は、x(t) のサンプル数に応じて、f = 1/T からナイキスト周波数 f_ny = 1/(2 dt) 以下までの周波数を与えることを思い出してください。偶数か奇数か。
これはpsdのpythonサンプルコードです
def psd(x,dt=1.):
"""Computes one-sided power spectral density of x.
PSD estimated via abs**2 of Fourier transform of x
Takes care of even or odd number of elements in x:
- if x is even both f=0 and Nyquist freq. appear once
- if x is odd f=0 appears once and Nyquist freq. does not appear
Note that there are no tapers applied: This may lead to leakage!
Parseval's theorem (Variance of time series equal to integral over PSD) holds and can be checked via
print ( np.var(x), sum(Px*f[1]) )
Accordingly, the etsimated PSD is independent of time series length
Author/date: M. von Papen / 16.03.2017
"""
N = np.size(x)
xf = np.fft.fft(x)
Px = abs(xf)**2./N*dt
f = np.arange(N/2+1)/(N*dt)
if np.mod(N,2) == 0:
Px[1:N/2] = 2.*Px[1:N/2]
else:
Px[1:N/2+1] = 2.*Px[1:N/2+1]
# Take one-sided spectrum
Px = Px[0:N/2+1]
return Px, f