【发布时间】:2010-11-04 23:29:24
【问题描述】:
有没有更好的方法来找到哪个 X 给了我我在 SciPy 中寻找的 Y?我刚开始使用 SciPy,对每个功能都不太熟悉。
import numpy as np
import matplotlib.pyplot as plt
from scipy import interpolate
x = [70, 80, 90, 100, 110]
y = [49.7, 80.6, 122.5, 153.8, 163.0]
tck = interpolate.splrep(x,y,s=0)
xnew = np.arange(70,111,1)
ynew = interpolate.splev(xnew,tck,der=0)
plt.plot(x,y,'x',xnew,ynew)
plt.show()
t,c,k=tck
yToFind = 140
print interpolate.sproot((t,c-yToFind,k)) #Lowers the spline at the abscissa
【问题讨论】:
-
你能详细说明你想变得更好吗?性能、准确性、简洁性?
标签: python numpy scipy interpolation scientific-computing