jax.scipy.signal.csd#
- jax.scipy.signal.csd(x, y, fs=1.0, window='hann', nperseg=None, noverlap=None, nfft=None, detrend='constant', return_onesided=True, scaling='density', axis=-1, average='mean')[source]#
Estimate cross power spectral density (CSD) using Welch’s method.
This is a JAX implementation of
scipy.signal.csd(). It is similar tojax.scipy.signal.welch(), but it operates on two input signals and estimates their cross-spectral density instead of the power spectral density (PSD).- Parameters:
x (Array) – Array representing a time series of input values.
y (ArrayLike | None) – Array representing the second time series of input values, the same length as
xalong the specifiedaxis. If not specified, then assumey = xand compute the PSDPxxofxvia Welch’s method.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) – Length of each segment (default: 256).
noverlap (int | None) – Number of points to overlap between segments (default:
nperseg // 2).nfft (int | 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 CSD 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, Pxy).fis the array of sample frequencies, andPxyis the cross spectral density of x and y- Return type:
Notes
The original SciPy function exhibits slightly different behavior between
csd(x, x)andcsd(x, x.copy()). The LAX-backend version is designed to follow the latter behavior. To replicate the former, call this function function ascsd(x, None).See also
jax.scipy.signal.welch(): Power spectral density.jax.scipy.signal.stft(): Short-time Fourier transform.