# cupyx.scipy.signal.freqz#

cupyx.scipy.signal.freqz(b, a=1, worN=512, whole=False, plot=None, fs=6.283185307179586, include_nyquist=False)[source]#

Compute the frequency response of a digital filter.

Given the M-order numerator b and N-order denominator a of a digital filter, compute its frequency response:

```            jw                 -jw              -jwM
jw    B(e  )    b + be    + ... + b[M]e
H(e  ) = ------ = -----------------------------------
jw                 -jw              -jwN
A(e  )    a + ae    + ... + a[N]e
```
Parameters
• b (array_like) – Numerator of a linear filter. If b has dimension greater than 1, it is assumed that the coefficients are stored in the first dimension, and `b.shape[1:]`, `a.shape[1:]`, and the shape of the frequencies array must be compatible for broadcasting.

• a (array_like) – Denominator of a linear filter. If b has dimension greater than 1, it is assumed that the coefficients are stored in the first dimension, and `b.shape[1:]`, `a.shape[1:]`, and the shape of the frequencies array must be compatible for broadcasting.

• worN ({None, int, array_like}, optional) –

If a single integer, then compute at that many frequencies (default is N=512). This is a convenient alternative to:

```cupy.linspace(0, fs if whole else fs/2, N,
endpoint=include_nyquist)
```

Using a number that is fast for FFT computations can result in faster computations (see Notes).

If an array_like, compute the response at the frequencies given. These are in the same units as fs.

• whole (bool, optional) – Normally, frequencies are computed from 0 to the Nyquist frequency, fs/2 (upper-half of unit-circle). If whole is True, compute frequencies from 0 to fs. Ignored if worN is array_like.

• plot (callable) – A callable that takes two arguments. If given, the return parameters w and h are passed to plot. Useful for plotting the frequency response inside freqz.

• fs (float, optional) – The sampling frequency of the digital system. Defaults to 2*pi radians/sample (so w is from 0 to pi).

• include_nyquist (bool, optional) – If whole is False and worN is an integer, setting include_nyquist to True will include the last frequency (Nyquist frequency) and is otherwise ignored.

Returns

• w (ndarray) – The frequencies at which h was computed, in the same units as fs. By default, w is normalized to the range [0, pi) (radians/sample).

• h (ndarray) – The frequency response, as complex numbers.

Notes

Using Matplotlib’s `matplotlib.pyplot.plot()` function as the callable for plot produces unexpected results, as this plots the real part of the complex transfer function, not the magnitude. Try `lambda w, h: plot(w, cupy.abs(h))`.

A direct computation via (R)FFT is used to compute the frequency response when the following conditions are met:

1. An integer value is given for worN.

2. worN is fast to compute via FFT (i.e., next_fast_len(worN) <scipy.fft.next_fast_len> equals worN).

3. The denominator coefficients are a single value (`a.shape == 1`).

4. worN is at least as long as the numerator coefficients (`worN >= b.shape`).

5. If `b.ndim > 1`, then `b.shape[-1] == 1`.

For long FIR filters, the FFT approach can have lower error and be much faster than the equivalent direct polynomial calculation.