0

ポイントが順序付けられていない、つまり「x」が減少しているデータセットから外挿する方法について、頭を悩ませることはできません。そのようです:

http://www.pic-host.org/images/2014/07/21/0b5ad6a11266f549.png

x 値と y 値のプロットを別々に作成する必要があることがわかりました。したがって、これを取得するコード: (ポイントは順序付けられます)

x = bananax
y = bananay

t = np.arange(x.shape[0], dtype=float) 
t /= t[-1]
nt = np.linspace(0, 1, 100) 

x1 = scipy.interpolate.spline(t, x, nt) 
y1 = scipy.interpolate.spline(t, y, nt)

plt.plot(nt, x1, label='data x')
plt.plot(nt, y1, label='data y')

これで、補間されたスプラインが得られました。f(nt)=x1 と f(nt)=y1 をそれぞれ外挿する必要があると思います。単純な線形回帰を使用してデータから補間する方法を取得しましたが、より複雑なスプライン (?) を推定する方法がありません。目的は、外挿された関数がデータポイントの曲率に従うようにすることです。(少なくとも片端では)

乾杯、そしてありがとう!

4

2 に答える 2

0

おかげで、これで正しい軌道に乗ることができました。私にとってうまくいったのは:

x = bananax
y = bananay

#------ fit a spline to the coordinates, x and y axis are interpolated towards t
t = np.arange(x.shape[0], dtype=float) #t is # of values
t /= t[-1] #t is now devided from 0 to 1
nt = np.linspace(0, 1, 100) #nt is array with values from 0 to 1 with 100 intermediate values

x1 = scipy.interpolate.spline(t, x, nt) #The x values where spline should estimate the y values
y1 = scipy.interpolate.spline(t, y, nt)

#------ create a new linear space for nnt in which an extrapolation from the interpolated spline will be made 
nnt = np.linspace(-1, 1, 100) #values <0 are extrapolated (interpolation started at the tip(=0)

x1fit = np.polyfit(nt,x1,3) #fits a polynomial function of the nth order with the spline as input, output are the function parameters
y1fit = np.polyfit(nt,y1,3)

xpoly = np.poly1d(x1fit) #genereates the function based on the parameters obtained by polyfit
ypoly = np.poly1d(y1fit)
于 2014-08-18T17:45:12.670 に答える