normalize#
- scipy.signal.normalize(b, a)[source]#
Normalize numerator/denominator of a continuous-time transfer function.
If values of b are too close to 0, they are removed. In that case, a BadCoefficients warning is emitted.
- Parameters:
- barray_like
Numerator of the transfer function. Can be a 2-D array to normalize multiple transfer functions.
- aarray_like
Denominator of the transfer function. At most 1-D.
- Returns:
- numarray
The numerator of the normalized transfer function. At least a 1-D array. A 2-D array if the input num is a 2-D array.
- den1-D array
The denominator of the normalized transfer function.
Notes
Coefficients for both the numerator and denominator should be specified in descending exponent order (e.g.,
s^2 + 3s + 5would be represented as[1, 3, 5]).Array API Standard Support
normalizehas support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.Library
CPU
GPU
NumPy
✅
n/a
CuPy
n/a
✅
PyTorch
✅
✅
JAX
⚠️ no JIT
⛔
Dask
⚠️ computes graph
n/a
See Support for the array API standard for more information.
Examples
>>> from scipy.signal import normalize
Normalize the coefficients of the transfer function
(3*s^2 - 2*s + 5) / (2*s^2 + 3*s + 1):>>> b = [3, -2, 5] >>> a = [2, 3, 1] >>> normalize(b, a) (array([ 1.5, -1. , 2.5]), array([1. , 1.5, 0.5]))
A warning is generated if, for example, the first coefficient of b is 0. In the following example, the result is as expected:
>>> import warnings >>> with warnings.catch_warnings(record=True, action='always') as w: ... num, den = normalize([0, 3, 6], [2, -5, 4])
>>> num array([1.5, 3. ]) >>> den array([ 1. , -2.5, 2. ])
>>> print(w[0].message) Badly conditioned filter coefficients (numerator): the results may be meaningless