scipy.signal.unique_roots¶
-
scipy.signal.
unique_roots
(p, tol=0.001, rtype='min')[source]¶ Determine unique roots and their multiplicities from a list of roots.
Parameters: p : array_like
The list of roots.
tol : float, optional
The tolerance for two roots to be considered equal. Default is 1e-3.
rtype : {‘max’, ‘min, ‘avg’}, optional
How to determine the returned root if multiple roots are within tol of each other.
- ‘max’: pick the maximum of those roots.
- ‘min’: pick the minimum of those roots.
- ‘avg’: take the average of those roots.
Returns: pout : ndarray
The list of unique roots, sorted from low to high.
mult : ndarray
The multiplicity of each root.
Notes
This utility function is not specific to roots but can be used for any sequence of values for which uniqueness and multiplicity has to be determined. For a more general routine, see
numpy.unique
.Examples
>>> from scipy import signal >>> vals = [0, 1.3, 1.31, 2.8, 1.25, 2.2, 10.3] >>> uniq, mult = signal.unique_roots(vals, tol=2e-2, rtype='avg')
Check which roots have multiplicity larger than 1:
>>> uniq[mult > 1] array([ 1.305])