spkit.periodogram

spkit.periodogram(x, fs=128, show_plot=False, method='welch', win='hann', nfft=None, scaling='density', average='mean', detrend='constant', nperseg=None, noverlap=None, showlog=True, show=False, label=None, return_frq=True)

Computing Periodogram

Computing Periodogram using Welch or Periodogram method

Parameters:
x: 1d array, (n,)
  • input signal,

fs: sampling frequency
method: {‘welch’,’None’}
  • if None, then periodogram is computed without welch method

win: {‘hann’, ‘ham’, ..}

: window function

scaling: {‘density’, ‘spectrum’}
  • ‘density’–V**2/Hz ‘spectrum’–V**2

average: {‘mean’, ‘median’}
  • averaging method

detrend: False, ‘constant’, ‘linear’
nfft: None, n-point FFT
Returns:
Pxarray, |periodogram|
Frqarray, frequency

See also

spkit

#TODO

Notes

#TODO

References

Examples

import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
x,fs = sp.load_data.eeg_sample_1ch()
Px1, frq1 = sp.periodogram(x,fs=128,method ='welch',nperseg=128)
Px2, frq2 = sp.periodogram(x,fs=128,method =None,nfft=128)
plt.figure(figsize=(5,4))
plt.plot(frq1,np.log(Px1),label='Welch')
plt.plot(frq2,np.log(Px2),label='Periodogram')
plt.xlim([frq[0],frq[-1]])
plt.grid()
plt.ylabel('V**2/Hz')
plt.xlabel('Frequency (Hz)')
plt.legend()
plt.show()