scipy.signal.

argrelextrema#

scipy.signal.argrelextrema(data, comparator, axis=0, order=1, mode='clip')[源代码]#

计算 data 的相对极值。

参数:
datandarray

用于查找相对极值的数组。

comparator可调用对象

用于比较两个数据点的函数。应接受两个数组作为参数。

axisint, 可选

用于从 data 中选择的轴。默认为 0。

orderint, 可选

在比较中,每侧要使用的点数,以使 comparator(n, n+x) 为 True。

modestr, 可选

向量边缘的处理方式。“wrap”(环绕)或“clip”(将溢出视为与最后一个(或第一个)元素相同)。默认为“clip”。参见 numpy.take

返回:
extremandarray 元组

整数数组中最大值的索引。extrema[k]data 在轴 k 上的索引数组。请注意,即使 data 是一维的,返回值也是一个元组。

另请参阅

argrelmin, argrelmax

注释

在 0.11.0 版本中添加。

示例

>>> import numpy as np
>>> from scipy.signal import argrelextrema
>>> x = np.array([2, 1, 2, 3, 2, 0, 1, 0])
>>> argrelextrema(x, np.greater)
(array([3, 6]),)
>>> y = np.array([[1, 2, 1, 2],
...               [2, 2, 0, 0],
...               [5, 3, 4, 4]])
...
>>> argrelextrema(y, np.less, axis=1)
(array([0, 2]), array([2, 1]))