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 to jax.scipy.signal.welch(), but it operates on two input signals and estimates their cross-spectral density instead of the power spectral density (PSD).

  • 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 x along the specified axis. If not specified, then assume y = x and compute the PSD Pxx of x via 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 is nperseg.

  • 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'.


A length-2 tuple of arrays (f, Pxy). f is the array of sample frequencies, and Pxy is the cross spectral density of x and y

Return type:

tuple[Array, Array]


The original SciPy function exhibits slightly different behavior between csd(x, x) and csd(x, x.copy()). The LAX-backend version is designed to follow the latter behavior. To replicate the former, call this function function as csd(x, None).

See also