Reputation: 31
I want to use python signal.welch. The usage of signal.welch is as follows,
f, Pxx_den = signal.welch(x, fs, nperseg=1024)
In my case, x is for example gyroscopy signal ( 1 x 1024 samples (for about 10 sec data)), fs = 100 Hz. In my case, how can I decide nperseg? I want to know how I can select nperseg when the number of samples of the input is 1024 (about 10 sec).
Upvotes: 3
Views: 9247
Reputation: 3271
scipy.signal.welch estimates the power spectral density by dividing the data into segments and averaging periodograms computed on each segment. The nperseg
arg is the segment length and (by default) also determines the FFT size.
On the one hand, making nperseg
smaller allows the input to divide into more segments, good for more averaging to get a more reliable estimate. On the other hand, making nperseg
larger improves the frequency resolution of the result. In any case, nperseg
should be smaller than the input size in order to get multiple segments.
The default segment length is 256 samples, which seems like a reasonable starting point for a 1024-sample input.
Upvotes: 5