日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python如何确定拐点_python – 在样条拟合1d数据中找到拐点

發(fā)布時間:2024/7/23 python 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python如何确定拐点_python – 在样条拟合1d数据中找到拐点 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我有一些一維數據,并與樣條擬合.然后我想在其中找到拐點(忽略鞍點).現在我通過在splev生成的很多值上使用scipy.signal.argrelmin(和argrelmax)來搜索其第一個派生的極值.

import scipy.interpolate

import scipy.optimize

import scipy.signal

import numpy as np

import matplotlib.pyplot as plt

import operator

y = [-1, 5, 6, 4, 2, 5, 8, 5, 1]

x = np.arange(0, len(y))

tck = scipy.interpolate.splrep(x, y, s=0)

print 'roots', scipy.interpolate.sproot(tck)

# output:

# [0.11381478]

xnew = np.arange(0, len(y), 0.01)

ynew = scipy.interpolate.splev(xnew, tck, der=0)

ynew_deriv = scipy.interpolate.splev(xnew, tck, der=1)

min_idxs = scipy.signal.argrelmin(ynew_deriv)

max_idxs = scipy.signal.argrelmax(ynew_deriv)

mins = zip(xnew[min_idxs].tolist(), ynew_deriv[min_idxs].tolist())

maxs = zip(xnew[max_idxs].tolist(), ynew_deriv[max_idxs].tolist())

inflection_points = sorted(mins + maxs, key=operator.itemgetter(0))

print 'inflection_points', inflection_points

# output:

# [(3.13, -2.9822449358974357),

# (5.03, 4.3817785256410255)

# (7.13, -4.867132628205128)]

plt.legend(['data','Cubic Spline', '1st deriv'])

plt.plot(x, y, 'o',

xnew, ynew, '-',

xnew, ynew_deriv, '-')

plt.show()

但這感覺非常錯誤.我想有可能在沒有產生這么多價值的情況下找到我要找的東西.像sproot這樣的東西,但也許適用于二次推導?

總結

以上是生活随笔為你收集整理的python如何确定拐点_python – 在样条拟合1d数据中找到拐点的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。