0
を得た:scipy.interpolate.pchipは、私は以下のコードを実行しようとしていますエラー
x = [0, 1, 2, 3, 4, 5]
y = [1, 2, 1.5, 2.5, 3, 2.5]
xs = np.linspace(x[0],x[-1],100)
curve = interpolate.pchip(x,y)
ys = curve(xs)
dys = curve.derivative(xs)
pl.plot(xs,ys,label=u'pchip')
pl.plot(xs,dys,label=u'derivative')
pl.plot(x,y,'o')
pl.legend(loc='best')
pl.grid()
pl.margins(0.1,0.1)
pl.show()
をしかし、このようなエラーました:私が使用してシステムがWindows + Python3.5である
ValueError Traceback (most recent call last)
<ipython-input-61-256eb8fb78c2> in <module>()
4 curve = interpolate.pchip(x,y)
5 ys = curve(xs)
----> 6 dys = curve.derivative(xs)#Construct a new piecewise polynomial
representing the derivative.
7 pl.plot(xs,ys,label=u'pchip')
8 pl.plot(xs,dys,label=u'1 class diff')
C:\Program Files\Anaconda3\lib\site-packages\scipy\interpolate\interpolate.py in derivative(self, nu)
1377
1378 """
-> 1379 if nu < 0:
1380 return self.antiderivative(-nu)
1381
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
を+ Anaconda + Jupyterノートブック。
ありがとうございます。
それはworkds。どうもありがとうございました! –
または最初の導関数を評価する 'curve(xs、1)'。 –