日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

python 尋找離散序列極值點的方法

系統 1857 0

使用 scipy.signal 的 argrelextrema 函數( API ),簡單方便

            
import numpy as np 
import pylab as pl
import matplotlib.pyplot as plt
import scipy.signal as signal
x=np.array([
  0, 6, 25, 20, 15, 8, 15, 6, 0, 6, 0, -5, -15, -3, 4, 10, 8, 13, 8, 10, 3,
  1, 20, 7, 3, 0 ])
plt.figure(figsize=(16,4))
plt.plot(np.arange(len(x)),x)
print x[signal.argrelextrema(x, np.greater)]
print signal.argrelextrema(x, np.greater)

plt.plot(signal.argrelextrema(x,np.greater)[0],x[signal.argrelextrema(x, np.greater)],'o')
plt.plot(signal.argrelextrema(-x,np.greater)[0],x[signal.argrelextrema(-x, np.greater)],'+')
# plt.plot(peakutils.index(-x),x[peakutils.index(-x)],'*')
plt.show()

          
            
[25 15 6 10 13 10 20]
(array([ 2, 6, 9, 15, 17, 19, 22]),)

          

但是存在一個問題,在極值有左右相同點的時候無法識別,但是個人認為在實際的使用過程中極少會出現這種情況,所以可以忽略。

            
x=np.array([
  0, 15, 15, 15, 15, 8, 15, 6, 0, 6, 0, -5, -15, -3, 4, 10, 8, 13, 8, 10, 3,
  1, 20, 7, 3, 0 ])
plt.figure(figsize=(16,4))
plt.plot(np.arange(len(x)),x)
print x[signal.argrelextrema(x, np.greater)]
print signal.argrelextrema(x, np.greater)

plt.plot(signal.argrelextrema(x,np.greater)[0],x[signal.argrelextrema(x, np.greater)],'o')
plt.plot(signal.argrelextrema(x,np.less)[0],x[signal.argrelextrema(x, np.less)],'+')
plt.show()

          
            
[15 6 10 13 10 20]
(array([ 6, 9, 15, 17, 19, 22]),)
          

以上這篇python 尋找離散序列極值點的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 兴海县| 天镇县| 中西区| 泰来县| 贞丰县| 绥中县| 吉水县| 柳河县| 茌平县| 视频| 罗甸县| 巩义市| 离岛区| 通城县| 河间市| 广宁县| 大名县| 安陆市| 日喀则市| 确山县| 岐山县| 荃湾区| 高邑县| 宝清县| 肇州县| 平阳县| 中山市| 梧州市| 汝城县| 清流县| 博白县| 江门市| 通化县| 尼勒克县| 农安县| 黑水县| 信宜市| 永吉县| 武穴市| 青铜峡市| 河津市|