Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从曲线数据点推断_Python_Image Processing_Scipy_Extrapolation - Fatal编程技术网

Python 从曲线数据点推断

Python 从曲线数据点推断,python,image-processing,scipy,extrapolation,Python,Image Processing,Scipy,Extrapolation,我不太明白如何从数据集中推断出点没有顺序的数据集,也就是说,对于“x”来说,数据集是递减的。像这样: 我得到,我需要分别为x和y值创建一个绘图。所以我得到的代码是:(点数是有序的) 现在我得到了插值样条曲线。我想我必须分别对f(nt)=x1和f(nt)=y1进行外推。我知道如何用一个简单的线性回归从数据中插值,但我不知道如何从中得到一个更复杂的样条(?)外推。 目的是让外推函数跟随数据点的曲率。(至少在一端) 干杯,谢谢 我认为您在正确的轨道上创建了参数曲线(创建x(t)和y(t)),因为点是

我不太明白如何从数据集中推断出点没有顺序的数据集,也就是说,对于“x”来说,数据集是递减的。像这样:

我得到,我需要分别为x和y值创建一个绘图。所以我得到的代码是:(点数是有序的)

现在我得到了插值样条曲线。我想我必须分别对f(nt)=x1和f(nt)=y1进行外推。我知道如何用一个简单的线性回归从数据中插值,但我不知道如何从中得到一个更复杂的样条(?)外推。 目的是让外推函数跟随数据点的曲率。(至少在一端)


干杯,谢谢

我认为您在正确的轨道上创建了参数曲线(创建x(t)和y(t)),因为点是有序的。问题的一部分似乎是
样条曲线
函数返回离散值,而不是样条曲线的形式和参数
scipy.optimize
有一些很好的工具,可以帮助您找到函数而不是计算点

如果您对生成数据的基本过程有任何了解,我建议您使用它来帮助选择用于拟合的函数形式。这些更自由形式的方法将为您提供一定程度的灵活性

安装x(t)和y(t)并保持最终的安装功能。它们将使用从
t=0
t=1
的数据生成,但没有任何*会阻止您在该范围之外对它们进行评估

我可以推荐以下链接来指导曲线拟合程序:

简称:

长:


*几乎没什么

谢谢这让我走上了正轨。对我起作用的是:

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)
x=bananax
y=bananay
#------将样条曲线拟合到坐标,x轴和y轴向t方向插值
t=np.arange(x.shape[0],dtype=float)#t是值的#
t/=t[-1]#t现在从0分为1
nt=np。linspace(0,1100)#nt是一个数组,值从0到1,中间值为100
x1=scipy.interpolate.spline(t,x,nt)#spline应该估计y值的x值
y1=scipy.插值样条曲线(t,y,nt)
#------为nnt创建一个新的线性空间,其中将从插值样条曲线进行外推
nnt=np.linspace(-1,1100)#值
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)