我想生成一个随机的时间序列,具有指定的光谱形状。为此,我将从适当的频谱分布中提取随机复傅立叶系数,然后将频率转换为时域。在
为了产生一个实时的时间序列,傅里叶频谱必须有真实的直流和奈奎斯特系数,并且具有对称的负频率。在
当我这样做的时候,我得到的行为与numpy的ifft
和它的irfft
不同。在
作为一个例子,这里有一个32个样本的白色光谱:
import numpy as np
Nsamp = 2**5
Nfreq = (Nsamp-1)//2 # num pos freq bins not including DC or Nyquist
DC = 0.
f_pos = np.random.randn(Nfreq) + 1j*np.random.randn(Nfreq)
Nyquist = np.random.randn() # this is real
f_neg = f_pos[::-1] # mirror pos freqs
f_tot = np.hstack((DC, f_pos, Nyquist, f_neg))
f_rep = np.hstack((DC, f_pos, Nyquist))
t1 = np.fft.ifft(f_tot)
t2 = np.fft.irfft(f_rep)
print(t1)
print(t2)
我希望t1
都是真实的,t1
和{
{I>正确使用cd1}?看看np.fft.fftfreq(Nsamp)
输出的频率,我认为我为输入正确地构建了f_tot
。在
irfft
是正确的结果,所以我将使用它。。。但我想知道未来如何使用ifft
。在
从^{
A[0]
contains the zero-frequency term (the sum of the signal), which is always purely real for real inputs. ThenA[1:n/2]
contains the positive-frequency terms, andA[n/2+1:]
contains the negative-frequency terms, in order of decreasingly negative frequency. For an even number of input points,A[n/2]
represents both positive and negative Nyquist frequency, and is also purely real for real input.
目前没有回答
相关问题 更多 >
编程相关推荐