當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python SciPy signal.argrelextrema用法及代碼示例

本文簡要介紹 python 語言中 scipy.signal.argrelextrema 的用法。

用法:

scipy.signal.argrelextrema(data, comparator, axis=0, order=1, mode='clip')#

計算數據的相對極值。

參數

data ndarray

在其中查找相對極值的數組。

comparator 可調用的

用於比較兩個數據點的函數。應該將兩個數組作為參數。

axis 整數,可選

從數據中選擇的軸。默認值為 0。

order 整數,可選

每邊有多少點用於比較認為comparator(n, n+x)為真。

mode str,可選

如何處理向量的邊。 ‘wrap’(環繞)或‘clip’(將溢出視為與最後一個(或第一個)元素相同)。默認為‘clip’。見 numpy.take

返回

extrema ndarray 的元組

整數數組中最大值的索引。extrema[k]是軸索引的數組k數據。請注意,即使在以下情況下,返回值也是一個元組數據是一維的。

注意

例子

>>> 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]))

相關用法


注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.signal.argrelextrema。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。