|
From: Becker, M. <M.B...@st...> - 2009-10-09 19:19:51
|
Hi, I am using the "fit" function in Gnuplot. The results are very good, even when fitting polynomials with large exponents. But when I try to evaluate the polynomial function (typing in the "final set of parameters" I get from gnuplot manually), the resulting curve is not the same as when plotting the function via f(x). Here's how you can reproduce that issue: testfit.txt: 0.703046801 6.148059 0.741713434 6.234822 0.773950468 6.266732 0.834634823 6.349324 0.858792937 6.367429 0.945874445 6.455779 1.018601748 6.493238 1.056631087 6.515271 1.132619496 6.561212 1.208396235 6.623743 1.273432446 6.626688 1.322841114 6.661144 1.361994398 6.699116 1.419894331 6.703436 1.449532378 6.745392 1.495365168 6.799023 1.535109234 6.797992 1.551450853 6.892794 1.591150493 7.062142 1.609838136 7.056377 1.644491435 7.110281 1.664403966 6.909729 1.693825512 7.008516 1.719950161 6.966135 1.73447221 7.010832 1.750159151 7.056173 1.757950486 7.011614 1.769690372 7.051956 1.776861121 7.299418 1.784387803 7.534082 1.793996571 7.368413 1.799427481 6.789878 1.809187046 6.787986 1.815111552 7.235731 1.820633772 6.987372 1.830313952 6.4942 1.839906457 6.455258 1.849030092 6.912105 1.857638041 5.93482 gnuplot> plot "testfit.txt" gnuplot> f(x)=a+b*x+c*x**2+d*x**3+e*x**4+f*x**5+g*x**6+h*x**7+i*x**8+j*x**9+k*x**10 gnuplot> fit f(x) "testfit.txt" via a,b,c,d,e,f,g,h,i,j,k ... Final set of parameters Asymptotic Standard Error ======================= ========================== a = -20719.6 +/- 4.261e+04 (205.6%) b = 186386 +/- 3.689e+05 (197.9%) c = -744986 +/- 1.419e+06 (190.4%) d = 1.74269e+06 +/- 3.191e+06 (183.1%) e = -2.64203e+06 +/- 4.648e+06 (175.9%) f = 2.71275e+06 +/- 4.585e+06 (169%) g = -1.91066e+06 +/- 3.102e+06 (162.3%) h = 911686 +/- 1.422e+06 (155.9%) i = -282112 +/- 4.227e+05 (149.8%) j = 51135.2 +/- 7.364e+04 (144%) k = -4124.11 +/- 5711 (138.5%) ... gnuplot> set multi gnuplot> plot "testfit.txt", f(x) -> fits perfectly! gnuplot> set xrange[0.6:2] gnuplot> set yrange[5.8:7.6] gnuplot> plot -20719.6+186386*x-744986*x**2+1.74269e+06*x**3-2.64203e+06*x**4+2.71275e+06*x**5-1.91066e+06*x**6+911686*x**7-282112*x**8+51135.2*x**9-4124.11*x**10 -> that seems to be a completely different curve! What can I do to get the correct fitting function (which is used internally by gnuplot - otherwise it wouldn't be able to show the correct fitting curve)? The problem might be that the coefficients I get from gnuplot's fit function are lacking some decimals, but I'm not sure about that. Any ideas? Thanks, Martin |