拟合平滑样条的等式是什么?

时间:2018-02-07 16:27:36

标签: r nonlinear-functions

我有.csv(附加数据文件)文件中的数据集,我想找到该数据的最佳拟合线。我无法使用非线性配件获得良好的拟合(可能我在R中使用非线性拟合很差)。 但我能够使用 smooth.spline 函数并正确拟合数据,如附图所示。我的要求是: 1.得到拟合样条函数的方程或 2.使用非线性拟合模型得到最佳拟合方程 这是我用来做smooth.spline拟合的命令

filePath = "E:/1_Modulated_function_pmf/R_Fitting/"
readData = read.csv(paste0(filePath, "data.csv"))
x_data<-readData$X_data
y_data<-readData$Y_data
plot(x_data,y_data)
spline <- smooth.spline(x_data,y_data,df=20)
lines(spline, col="red")

我想得到拟合样条函数的方程。获取样条函数方程的语法是什么?或使用最佳非线性拟合模型拟合数据。 X和Y数据如下:

X_data(2.96E-01,2.98E-01,3.00E-01,3.02E-01,3.04E-01,3.06E-01,3.08E-01,3.10E-01,3.12E-01,3.14E-01,3.16E-01,3.18E-01,3.20E-01,3.22E-01,3.24E-01,3.26E-01,3.28E-01,3.30E-01,3.32E-01,3.34E-01,3.36E-01,3.38E-01,3.40E-01,3.42E-01,3.44E-01,3.46E-01,3.48E-01,3.50E-01,3.52E-01,3.54E-01,3.56E-01,3.58E-01,3.60E-01,3.62E-01,3.64E-01,3.66E-01,3.68E-01,3.70E-01,3.72E-01,3.74E-01,3.76E-01,3.78E-01,3.80E-01,3.82E-01,3.84E-01,3.86E-01,3.88E-01,3.90E-01,3.92E-01,3.94E-01,3.96E-01,3.98E-01,4.00E-01,4.02E-01,4.04E-01,4.06E-01,4.08E-01,4.10E-01,4.12E-01,4.14E-01,4.16E-01,4.18E-01,4.20E-01,4.22E-01,4.24E-01,4.26E-01,4.28E-01,4.30E-01,4.32E-01,4.34E-01,4.36E-01,4.38E-01,4.40E-01,4.42E-01,4.44E-01,4.46E-01,4.48E-01,4.50E-01,4.52E-01,4.54E-01,4.56E-01,4.58E-01,4.60E-01,4.62E-01,4.64E-01,4.66E-01,4.68E-01,4.70E-01,4.72E-01,4.74E-01,4.76E-01,4.78E-01,4.80E-01,4.82E-01,4.84E-01,4.86E-01,4.88E-01,4.90E-01,4.92E-01,4.94E-01,4.96E-01,4.98E-01,5.00E-01,5.02E-01,5.04E-01,5.06E-01,5.08E-01,5.10E-01,5.12E-01,5.14E-01,5.16E-01,5.18E-01,5.20E-01,5.22E-01,5.24E-01,5.26E-01,5.28E-01,5.30E-01,5.32E-01,5.34E-01,5.36E-01,5.38E-01,5.40E-01,5.42E-01,5.44E-01,5.46E-01,5.48E-01,5.50E-01,5.52E-01,5.54E-01,5.56E-01,5.58E-01,5.60E-01,5.62E-01,5.64E-01,5.66E-01,5.68E-01,5.70E-01,5.72E-01,5.74E-01,5.76E-01,5.78E-01,5.80E-01,5.82E-01,5.84E-01,5.86E-01,5.88E-01,5.90E-01,5.92E-01,5.94E-01,5.96E-01,5.98E-01,6.00E-01,6.02E-01,6.04E-01,6.06E-01,6.08E-01,6.10E-01,6.12E-01,6.14E-01,6.16E-01,6.18E-01,6.20E-01,6.22E-01,6.24E-01,6.26E-01,6.28E-01,6.30E-01,6.32E-01,6.34E-01,6.36E-01,6.38E-01,6.40E-01,6.42E-01,6.44E-01,6.46E-01,6.48E-01,6.50E-01,6.52E-01,6.54E-01,6.56E-01,6.58E-01,6.60E-01,6.62E-01,6.64E-01,6.66E-01,6.68E-01,6.70E-01,6.72E-01,6.74E-01,6.76E-01,6.78E-01,6.80E-01,6.82E-01,6.84E-01,6.86E-01,6.88E-01,6.90E-01,6.92E-01,6.94E-01,6.96E-01,6.98E-01,7.00E-01,7.02E-01,7.04E-01,7.06E-01,7.08E-01,7.10E-01,7.12E-01,7.14E-01,7.16E-01,7.18E-01,7.20E-01,7.22E-01,7.24E-01,7.26E-01,7.28E-01,7.30E-01,7.32E-01,7.34E-01,7.36E-01,7.38E-01,7.40E-01,7.42E-01,7.44E-01,7.46E-01,7.48E-01,7.50E-01,7.52E-01,7.54E-01,7.56E-01,7.58E-01,7.60E-01,7.62E-01,7.64E-01,7.66E-01,7.68E-01,7.70E-01,7.72E-01,7.74E-01,7.76E-01,7.78E-01,7.80E-01,7.82E-01,7.84E-01,7.86E-01,7.88E-01,7.90E-01,7.92E-01,7.94E-01,7.96E-01,7.98E-01,8.00E-01,8.02E-01,8.04E-01,8.06E-01,8.08E-01,8.10E-01,8.12E-01,8.14E-01,8.16E-01,8.18E-01,8.20E-01,8.22E-01,8.24E-01,8.26E-01,8.28E-01,8.30E-01,8.32E-01,8.34E-01,8.36E-01,8.38E-01,8.40E-01,8.42E-01,8.44E-01,8.46E-01,8.48E-01,8.50E-01,8.52E-01,8.54E-01,8.56E-01,8.58E-01,8.60E-01,8.62E-01,8.64E-01,8.66E-01,8.68E-01,8.70E-01,8.72E-01,8.74E-01,8.76E-01,8.78E-01,8.80E-01,8.82E-01,8.84E-01,8.86E-01,8.88E-01,8.90E-01,8.92E-01,8.94E-01,8.96E-01,8.98E-01,9.00E-01,9.02E-01,9.04E-01,9.06E-01,9.08E-01,9.10E-01,9.12E-01,9.14E-01,9.16E-01,9.18E-01,9.20E-01,9.22E-01,9.24E-01,9.26E-01,9.28E-01,9.30E-01,9.32E-01,9.34E-01,9.36E-01,9.38E-01,9.40E-01,9.42E-01,9.44E-01,9.46E-01,9.48E-01,9.50E-01,9.52E-01,9.54E-01,9.56E-01,9.58E-01,9.60E-01,9.62E-01,9.64E-01,9.66E-01,9.68E-01,9.70E-01,9.72E-01,9.74E-01,9.76E-01,9.78E-01,9.80E-01,9.82E-01,9.84E-01,9.86E-01,9.88E-01,9.90E-01,9.92E-01,9.94E-01,9.96E-01,9.98E-01,1.00E+00,1.00E+00,1.00E+00,1.01E+00,1.01E+00,1.01E+00,1.01E+00,1.01E+00,1.02E+00,1.02E+00,1.02E+00,1.02E+00,1.02E+00,1.03E+00,1.03E+00,1.03E+00,1.03E+00,1.03E+00,1.04E+00,1.04E+00,1.04E+00,1.04E+00,1.04E+00,1.05E+00,1.05E+00,1.05E+00,1.05E+00,1.05E+00,1.06E+00,1.06E+00,1.06E+00,1.06E+00,1.06E+00,1.07E+00,1.07E+00,1.07E+00,1.07E+00,1.07E+00,1.08E+00,1.08E+00,1.08E+00,1.08E+00,1.08E+00,1.09E+00,1.09E+00,1.09E+00,1.09E+00,1.09E+00,1.10E+00,1.10E+00,1.10E+00,1.10E+00,1.10E+00,1.11E+00,1.11E+00,1.11E+00,1.11E+00,1.11E+00,1.12E+00,1.12E+00,1.12E+00,1.12E+00,1.12E+00,1.13E+00,1.13E+00,1.13E+00,1.13E+00,1.13E+00,1.14E+00,1.14E+00,1.14E+00,1.14E+00,1.14E+00,1.15E+00,1.15E+00,1.15E+00,1.15E+00,1.15E+00,1.16E+00,1.16E+00,1.16E+00,1.16E+00,1.16E+00,1.17E+00,1.17E+00,1.17E+00,1.17E+00,1.17E+00,1.18E+00,1.18E+00,1.18E+00,1.18E+00,1.18E+00,1.19E+00,1.19E+00,1.19E+00,1.19E+00,1.19E+00,1.20E+00)
Y_data(8.10E+00,6.34E+00,5.29E+00,4.69E+00,4.34E+00,4.11E+00,3.93E+00,3.77E+00,3.62E+00,3.48E+00,3.33E+00,3.19E+00,3.05E+00,2.92E+00,2.79E+00,2.66E+00,2.53E+00,2.41E+00,2.29E+00,2.16E+00,2.04E+00,1.91E+00,1.79E+00,1.67E+00,1.55E+00,1.44E+00,1.32E+00,1.21E+00,1.11E+00,1.01E+00,9.06E-01,8.10E-01,7.17E-01,6.28E-01,5.44E-01,4.65E-01,3.90E-01,3.22E-01,2.59E-01,2.02E-01,1.51E-01,1.06E-01,6.79E-02,3.64E-02,1.17E-02,-5.97E-03,-1.68E-02,-2.10E-02,-1.86E-02,-1.01E-02,4.13E-03,2.38E-02,4.83E-02,7.71E-02,1.10E-01,1.45E-01,1.83E-01,2.23E-01,2.63E-01,3.04E-01,3.45E-01,3.85E-01,4.25E-01,4.64E-01,5.01E-01,5.38E-01,5.73E-01,6.08E-01,6.41E-01,6.74E-01,7.06E-01,7.39E-01,7.71E-01,8.03E-01,8.34E-01,8.66E-01,8.97E-01,9.28E-01,9.58E-01,9.87E-01,1.02E+00,1.04E+00,1.07E+00,1.10E+00,1.12E+00,1.14E+00,1.16E+00,1.18E+00,1.20E+00,1.21E+00,1.23E+00,1.24E+00,1.25E+00,1.25E+00,1.26E+00,1.26E+00,1.26E+00,1.26E+00,1.26E+00,1.25E+00,1.25E+00,1.24E+00,1.23E+00,1.22E+00,1.21E+00,1.19E+00,1.18E+00,1.16E+00,1.15E+00,1.13E+00,1.11E+00,1.09E+00,1.07E+00,1.05E+00,1.03E+00,1.01E+00,9.85E-01,9.64E-01,9.44E-01,9.23E-01,9.03E-01,8.83E-01,8.64E-01,8.45E-01,8.27E-01,8.09E-01,7.92E-01,7.75E-01,7.59E-01,7.43E-01,7.28E-01,7.13E-01,6.99E-01,6.85E-01,6.71E-01,6.58E-01,6.45E-01,6.32E-01,6.21E-01,6.10E-01,6.00E-01,5.90E-01,5.81E-01,5.72E-01,5.64E-01,5.57E-01,5.49E-01,5.42E-01,5.35E-01,5.29E-01,5.23E-01,5.17E-01,5.12E-01,5.07E-01,5.03E-01,4.99E-01,4.96E-01,4.94E-01,4.91E-01,4.89E-01,4.87E-01,4.85E-01,4.83E-01,4.82E-01,4.81E-01,4.81E-01,4.81E-01,4.82E-01,4.83E-01,4.84E-01,4.86E-01,4.88E-01,4.90E-01,4.93E-01,4.96E-01,4.99E-01,5.03E-01,5.07E-01,5.11E-01,5.15E-01,5.20E-01,5.25E-01,5.31E-01,5.36E-01,5.42E-01,5.48E-01,5.54E-01,5.59E-01,5.65E-01,5.71E-01,5.77E-01,5.83E-01,5.89E-01,5.94E-01,6.00E-01,6.05E-01,6.10E-01,6.15E-01,6.20E-01,6.25E-01,6.29E-01,6.33E-01,6.36E-01,6.40E-01,6.43E-01,6.46E-01,6.49E-01,6.51E-01,6.54E-01,6.56E-01,6.57E-01,6.58E-01,6.59E-01,6.60E-01,6.60E-01,6.60E-01,6.59E-01,6.59E-01,6.58E-01,6.57E-01,6.56E-01,6.55E-01,6.53E-01,6.52E-01,6.50E-01,6.49E-01,6.47E-01,6.45E-01,6.43E-01,6.41E-01,6.40E-01,6.38E-01,6.35E-01,6.33E-01,6.31E-01,6.29E-01,6.26E-01,6.24E-01,6.22E-01,6.20E-01,6.18E-01,6.17E-01,6.15E-01,6.13E-01,6.11E-01,6.09E-01,6.07E-01,6.06E-01,6.04E-01,6.03E-01,6.02E-01,6.01E-01,6.00E-01,5.99E-01,5.98E-01,5.97E-01,5.96E-01,5.95E-01,5.95E-01,5.94E-01,5.94E-01,5.93E-01,5.93E-01,5.92E-01,5.91E-01,5.91E-01,5.90E-01,5.90E-01,5.90E-01,5.90E-01,5.90E-01,5.90E-01,5.90E-01,5.91E-01,5.91E-01,5.91E-01,5.91E-01,5.92E-01,5.92E-01,5.92E-01,5.93E-01,5.93E-01,5.93E-01,5.93E-01,5.94E-01,5.94E-01,5.94E-01,5.94E-01,5.95E-01,5.95E-01,5.96E-01,5.96E-01,5.97E-01,5.97E-01,5.97E-01,5.98E-01,5.98E-01,5.99E-01,5.99E-01,5.99E-01,6.00E-01,6.00E-01,6.01E-01,6.01E-01,6.02E-01,6.02E-01,6.03E-01,6.04E-01,6.04E-01,6.05E-01,6.06E-01,6.06E-01,6.07E-01,6.07E-01,6.07E-01,6.07E-01,6.08E-01,6.08E-01,6.08E-01,6.08E-01,6.08E-01,6.09E-01,6.09E-01,6.10E-01,6.10E-01,6.11E-01,6.11E-01,6.11E-01,6.11E-01,6.12E-01,6.11E-01,6.11E-01,6.11E-01,6.11E-01,6.11E-01,6.11E-01,6.12E-01,6.12E-01,6.11E-01,6.11E-01,6.11E-01,6.11E-01,6.11E-01,6.11E-01,6.11E-01,6.11E-01,6.10E-01,6.10E-01,6.10E-01,6.10E-01,6.09E-01,6.09E-01,6.09E-01,6.09E-01,6.08E-01,6.08E-01,6.08E-01,6.08E-01,6.08E-01,6.08E-01,6.07E-01,6.07E-01,6.06E-01,6.06E-01,6.05E-01,6.05E-01,6.05E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.03E-01,6.03E-01,6.03E-01,6.03E-01,6.03E-01,6.03E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.04E-01,6.03E-01,6.03E-01,6.03E-01,6.02E-01,6.02E-01,6.02E-01,6.01E-01,6.01E-01,6.01E-01,6.00E-01,6.00E-01,5.99E-01,5.99E-01,5.98E-01,5.98E-01,5.97E-01,5.97E-01,5.96E-01,5.96E-01,5.95E-01,5.94E-01,5.94E-01,5.93E-01,5.92E-01,5.91E-01,5.90E-01,5.90E-01,5.89E-01,5.88E-01,5.87E-01,5.86E-01,5.85E-01,5.84E-01,5.83E-01,5.82E-01,5.81E-01,5.80E-01,5.80E-01,5.79E-01,5.78E-01,5.77E-01,5.76E-01,5.75E-01,5.74E-01,5.73E-01,5.72E-01,5.71E-01,5.70E-01,5.69E-01,5.68E-01,5.67E-01,5.66E-01)

enter image description here

0 个答案:

没有答案