Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/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
在gnuplot中拟合曲线:重复拟合会得到不同的结果_Gnuplot_Curve Fitting_Data Fitting - Fatal编程技术网

在gnuplot中拟合曲线:重复拟合会得到不同的结果

在gnuplot中拟合曲线:重复拟合会得到不同的结果,gnuplot,curve-fitting,data-fitting,Gnuplot,Curve Fitting,Data Fitting,我一直在尝试将方程y=Ax^2+Bx+C拟合到以下数据集(data.txt): 在gnuplot中,我键入了以下命令: fit a*x**2 + b*x + c 'data.txt' via a, b, c fit a*x**2 + b*x + c 'data.txt' via a, b, c 结果是: Final set of parameters Asymptotic Standard Error =======================

我一直在尝试将方程y=Ax^2+Bx+C拟合到以下数据集(data.txt):

在gnuplot中,我键入了以下命令:

fit a*x**2 + b*x + c 'data.txt' via a, b, c
fit a*x**2 + b*x + c 'data.txt' via a, b, c
结果是:

Final set of parameters            Asymptotic Standard Error
=======================            ==========================
a               = -1.73185e-20     +/- 2.658e-11    (1.535e+11%)
b               = 1                +/- 0.1325       (13.25%)
c               = 1                +/- 1.076e+09    (1.076e+11%)

correlation matrix of the fit parameters:
                a      b      c      
a               1.000 
b              -0.000  1.000 
c              -0.739  0.000  1.000 
当我使用a、b、c的值进行绘图时,数据和拟合线之间没有拟合

所以我再次发出命令

fit a*x**2 + b*x + c 'data.txt' via a, b, c
然后gnuplot输出以下输出:

Final set of parameters            Asymptotic Standard Error
=======================            ==========================
a               = -1.73185e-20     +/- 3.278e-21    (18.93%)
b               = -2.24969e-22     +/- 1.645e-11    (7.313e+12%)
c               = 1                +/- 0.1327       (13.27%)

correlation matrix of the fit parameters:
                a      b      c      
a               1.000 
b               0.000  1.000 
c              -0.739 -0.001  1.000
a、b、c的值发生了变化,但这也不能与数据进行令人满意的拟合。 因此,我再次发出命令:

fit a*x**2 + b*x + c 'data.txt' via a, b, c
fit a*x**2 + b*x + c 'data.txt' via a, b, c
这一次将吐出以下结果:

Final set of parameters            Asymptotic Standard Error
=======================            ==========================
a               = 1.96019e-39      +/- 5.98e-33     (3.051e+08%)
b               = -2.24969e-22     +/- 2.98e-23     (13.25%)
c               = -1.11942e-21     +/- 2.421e-13    (2.162e+10%)

correlation matrix of the fit parameters:
                a      b      c      
a               1.000 
b               0.000  1.000 
c              -0.739 -0.000  1.000 
这也没有给出令人满意的拟合

然后,我再次重复fit命令,得到以下结果:

After 4 iterations the fit converged.
final sum of squares of residuals : 2.4063e-39
abs. change during last iteration : -2.64182e-48


Hmmmm.... Sum of squared residuals is zero. Can't compute errors.

Final set of parameters 
======================= 

a               = 1.96019e-39    
b               = 2.01689e-41    
c               = -1.11942e-21
现在a,b,c的值与数据非常吻合

我的问题是:

  • 为什么a、b、c的值与第一次、第二次和第三次尝试的数据不匹配

  • 我可以使用最后计算的a、b、c值吗

  • 在最后一次尝试的输出中,我是否应该担心消息“Hmmmm…残差平方和为零。无法计算错误。”


  • 我认为你的数值范围太宽了,我猜一些计算(比如残差)由于截断误差是错误的

    如果通过将第一列乘以10^-9,第二列乘以10^-18来规范化数据

    -9.39398 0.152819
    -9.07008 0.150337
    -8.74617 0.144628
    -8.42227 0.137837
    -8.09817 0.131042
    -7.77427 0.124624
    -7.45037 0.118873
    -7.12646 0.111213
    -6.80256 0.100253
    -6.47865 0.0895713
    -6.15475 0.0792741
    -5.83066 0.0694736
    -5.50675 0.0602803
    -5.18285 0.051667
    -4.85894 0.0437442
    -4.53504 0.0365056
    -4.21113 0.0300328
    -3.88723 0.024281
    -3.56332 0.0193223
    -3.23923 0.0149467
    -2.91533 0.0113226
    -2.59142 0.00833933
    -2.26752 0.00593767
    -1.94361 0.00405992
    -1.61971 0.00264039
    -1.295810 0.001623
    -0.971713 0.00090523
    -0.647809 0.000405351
    -0.323904 0.0000897219
    0 0
    0.323904 0.0000897219
    0.647809 0.000405351
    0.971713 0.00090523
    1.295810 0.001623
    1.61971 0.00264039
    1.94361 0.00405992
    2.26752 0.00593767
    2.59142 0.00833933
    2.91533 0.0113226
    3.23923 0.0149467
    3.56332 0.0193223
    3.88723 0.024281
    4.21113 0.0300328
    4.53504 0.0365056
    4.85894 0.0437442
    5.18285 0.051667
    5.50675 0.0602803
    5.83066 0.0694736
    6.15475 0.0792741
    6.47865 0.0895713
    6.80256 0.100253
    7.12646 0.111213
    7.45037 0.118873
    7.77427 0.124624
    8.09817 0.131042
    8.42227 0.137837
    8.74617 0.144628
    9.07008 0.150337
    9.39398 0.152819
    
    然后

    是稳定的


    如果A、B、C是标准化数据中的拟合参数,则可以通过以下方式获得初始A、B、C参数(与原始数据对应的参数):

    解释/更新2:

    让(xi,yi),i=1,2,…n作为初始数据,您希望拟合:

    y ≈ a x^2 + b x + c
    
    但是,对于您的计算机,最好使用:

    Y ≈ A X^2 + B X + C
    
    其中X=10^-9x,Y=10^18y

    要从a、b、c中找到a、b、c,只需进行标识:

    Y ≈ A X^2 + B X + C => 10^18 y ≈ A 10^-18 x^2 + B 10^-9 x + C
                        =>       y ≈ A 10^-36 x^2 + B 10^-27 x + C 10^-18
          to be compared to      y ≈ a x^2        + b x        + c 
    
    因此,您有:

    a = A * 10^-36
    b = B * 10^-27
    c = C * 10^-18
    

    现在可以了吗?

    我认为你的值的数值范围太大了,我猜有些计算(比如残差)由于截断错误而出错

    如果通过将第一列乘以10^-9,第二列乘以10^-18来规范化数据

    -9.39398 0.152819
    -9.07008 0.150337
    -8.74617 0.144628
    -8.42227 0.137837
    -8.09817 0.131042
    -7.77427 0.124624
    -7.45037 0.118873
    -7.12646 0.111213
    -6.80256 0.100253
    -6.47865 0.0895713
    -6.15475 0.0792741
    -5.83066 0.0694736
    -5.50675 0.0602803
    -5.18285 0.051667
    -4.85894 0.0437442
    -4.53504 0.0365056
    -4.21113 0.0300328
    -3.88723 0.024281
    -3.56332 0.0193223
    -3.23923 0.0149467
    -2.91533 0.0113226
    -2.59142 0.00833933
    -2.26752 0.00593767
    -1.94361 0.00405992
    -1.61971 0.00264039
    -1.295810 0.001623
    -0.971713 0.00090523
    -0.647809 0.000405351
    -0.323904 0.0000897219
    0 0
    0.323904 0.0000897219
    0.647809 0.000405351
    0.971713 0.00090523
    1.295810 0.001623
    1.61971 0.00264039
    1.94361 0.00405992
    2.26752 0.00593767
    2.59142 0.00833933
    2.91533 0.0113226
    3.23923 0.0149467
    3.56332 0.0193223
    3.88723 0.024281
    4.21113 0.0300328
    4.53504 0.0365056
    4.85894 0.0437442
    5.18285 0.051667
    5.50675 0.0602803
    5.83066 0.0694736
    6.15475 0.0792741
    6.47865 0.0895713
    6.80256 0.100253
    7.12646 0.111213
    7.45037 0.118873
    7.77427 0.124624
    8.09817 0.131042
    8.42227 0.137837
    8.74617 0.144628
    9.07008 0.150337
    9.39398 0.152819
    
    然后

    是稳定的


    如果A、B、C是标准化数据中的拟合参数,则可以通过以下方式获得初始A、B、C参数(与原始数据对应的参数):

    解释/更新2:

    让(xi,yi),i=1,2,…n作为初始数据,您希望拟合:

    y ≈ a x^2 + b x + c
    
    但是,对于您的计算机,最好使用:

    Y ≈ A X^2 + B X + C
    
    其中X=10^-9x,Y=10^18y

    要从a、b、c中找到a、b、c,只需进行标识:

    Y ≈ A X^2 + B X + C => 10^18 y ≈ A 10^-18 x^2 + B 10^-9 x + C
                        =>       y ≈ A 10^-36 x^2 + B 10^-27 x + C 10^-18
          to be compared to      y ≈ a x^2        + b x        + c 
    
    因此,您有:

    a = A * 10^-36
    b = B * 10^-27
    c = C * 10^-18
    

    现在可以了吗?

    有没有办法从标准化数据的a、b、c值中获取,从非标准化数据的a、b、c值中获取?能否请您为更新中提到的公式提供参考?当我尝试将第二列乘以1E20时,没有办法从a、b、c值中获取,c对于规范化数据,a、b、c的值对于非规范化数据?您能为更新中提到的公式提供参考吗?当我尝试将第二列乘以1E20时,它不起作用