cupyx.scipy.signal.firls#

cupyx.scipy.signal.firls(numtaps, bands, desired, weight=None, fs=2)[source]#

FIR filter design using least-squares error minimization.

Calculate the filter coefficients for the linear-phase finite impulse response (FIR) filter which has the best approximation to the desired frequency response described by bands and desired in the least squares sense (i.e., the integral of the weighted mean-squared error within the specified bands is minimized).

Parameters:
  • numtaps (int) – The number of taps in the FIR filter. numtaps must be odd.

  • bands (array_like) – A monotonic nondecreasing sequence containing the band edges in Hz. All elements must be non-negative and less than or equal to the Nyquist frequency given by fs/2. The bands are specified as frequency pairs, thus, if using a 1D array, its length must be even, e.g., cupy.array([0, 1, 2, 3, 4, 5]). Alternatively, the bands can be specified as an nx2 sized 2D array, where n is the number of bands, e.g, cupy.array([[0, 1], [2, 3], [4, 5]]). All elements of bands must be monotonically nondecreasing, have width > 0, and must not overlap. (This is not checked by the routine).

  • desired (array_like) – A sequence the same size as bands containing the desired gain at the start and end point of each band. All elements must be non-negative (this is not checked by the routine).

  • weight (array_like, optional) – A relative weighting to give to each band region when solving the least squares problem. weight has to be half the size of bands. All elements must be non-negative (this is not checked by the routine).

  • fs (float, optional) – The sampling frequency of the signal. Each frequency in bands must be between 0 and fs/2 (inclusive). Default is 2.

Returns:

coeffs – Coefficients of the optimal (in a least squares sense) FIR filter.

Return type:

ndarray