invresz#
- scipy.signal.invresz(r, p, k, tol=0.001, rtype='avg')[source]#
Compute b(z) and a(z) from partial fraction expansion.
If M is the degree of numerator b and N the degree of denominator a:
b(z) b[0] + b[1] z**(-1) + ... + b[M] z**(-M) H(z) = ------ = ------------------------------------------ a(z) a[0] + a[1] z**(-1) + ... + a[N] z**(-N)
then the partial-fraction expansion H(z) is defined as:
r[0] r[-1] = --------------- + ... + ---------------- + k[0] + k[1]z**(-1) ... (1-p[0]z**(-1)) (1-p[-1]z**(-1))
If there are any repeated roots (closer than tol), then the partial fraction expansion has terms like:
r[i] r[i+1] r[i+n-1] -------------- + ------------------ + ... + ------------------ (1-p[i]z**(-1)) (1-p[i]z**(-1))**2 (1-p[i]z**(-1))**n
This function is used for polynomials in negative powers of z, such as digital filters in DSP. For positive powers, use
invres.- Parameters:
- rarray_like
Residues corresponding to the poles. For repeated poles, the residues must be ordered to correspond to ascending by power fractions.
- parray_like
Poles. Equal poles must be adjacent.
- karray_like
Coefficients of the direct polynomial term.
- tolfloat, optional
The tolerance for two roots to be considered equal in terms of the distance between them. Default is 1e-3. See
unique_rootsfor further details.- rtype{‘avg’, ‘min’, ‘max’}, optional
Method for computing a root to represent a group of identical roots. Default is ‘avg’. See
unique_rootsfor further details.
- Returns:
- bndarray
Numerator polynomial coefficients.
- andarray
Denominator polynomial coefficients.
See also
Examples
The following example builds b(z) / a(z) back from its partial-fraction expansion:
>>> import numpy as np >>> from scipy import signal >>> r = np.array([-2.2, 3.2]) >>> p = np.array([0.25, 0.5]) >>> k = np.array([]) >>> b, a = signal.invresz(r, p, k) >>> b array([1. , 0.3]) >>> a array([ 1. , -0.75 , 0.125])
Use
residuezto get back the expansion:>>> signal.residuez(b, a) (array([-2.2, 3.2]), array([0.25, 0.5 ]), array([], dtype=float64))
A non-empty k adds the direct term:
>>> r = np.array([0.4]) >>> p = np.array([0.5]) >>> k = np.array([1.6, -0.2]) >>> b, a = signal.invresz(r, p, k) >>> b, a (array([ 2. , -1. , 0.1]), array([ 1. , -0.5]))