0
$\begingroup$

I am trying to use FFT and power spectra density estimation with python (np.fft.fftand scipy.signal.periodogram). And trying to test it just with simple sin function. To get the same amplitude of FFT peak as amplitude of signal I do the following normalization:

freqs = np.fft.fftfreq(len(x), 1/f_s)  #generate frequencies -f_s/2 to f_s/2
signal_fft_norm=np.fft.fftshift(2*abs(signal_fft)/(len(x)))  #normalize signal and center the frequencies

(where f_s is sampling frequency, x is the signal). This works fine, shows same magnitude of the peak as amplitude of the signal. But I have issues with power spectral density. I am expecting to have just squared magnitude of the FFT peak. However, it's not the case, and normalization over the amount of samples also wouldn't give any adequate result. So my question is, how should I normalize it, to get the same magnitude? If my understanding that I should expect to have the same one is correct. I use the following code to calculate periodogram:

def calcul_spectrogram(x, fs):
    f, Pxx_den = periodogram(x, fs)
    P = np.sqrt(Pxx_den)
    return f, P

Image of the plots which I am getting is also attached.(signal, normalized FFT of signal, PSD in linear and log scale)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.