jax.scipy.signal.welch#
- jax.scipy.signal.welch(x, fs=1.0, window='hann', nperseg=None, noverlap=None, nfft=None, detrend='constant', return_onesided=True, scaling='density', axis=-1, average='mean')[source]#
Estimate power spectral density (PSD) using Welch’s method.
This is a JAX implementation of
scipy.signal.welch()
. It divides the input signal into overlapping segments, computes the modified periodogram for each segment, and averages the results to obtain a smoother estimate of the PSD.- Parameters:
x (Array) – Array representing a time series of input values.
fs (ArrayLike) – Sampling frequency of the inputs (default: 1.0).
window (str) – Data tapering window to apply to each segment. Can be a window function name, a tuple specifying a window length and function, or an array (default:
'hann'
).nperseg (int | None | None) – Length of each segment (default: 256).
noverlap (int | None | None) – Number of points to overlap between segments (default:
nperseg // 2
).nfft (int | None | None) – Length of the FFT used, if a zero-padded FFT is desired. If
None
(default), the FFT length isnperseg
.detrend (str) – Specifies how to detrend each segment. Can be
False
(default: no detrending),'constant'
(remove mean),'linear'
(remove linear trend), or a callable accepting a segment and returning a detrended segment.return_onesided (bool) – If True (default), return a one-sided spectrum for real inputs. If False, return a two-sided spectrum.
scaling (str) – Selects between computing the power spectral density (
'density'
, default) or the power spectrum ('spectrum'
)axis (int) – Axis along which the PSD is computed (default: -1).
average (str) – The type of averaging to use on the periodograms; one of
'mean'
(default) or'median'
.
- Returns:
A length-2 tuple of arrays
(f, Pxx)
.f
is the array of sample frequencies, andPxx
is the power spectral density ofx
.- Return type:
See also
jax.scipy.signal.csd()
: Cross power spectral density.jax.scipy.signal.stft()
: Short-time Fourier transform.