Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Eckard Specht <specht@hy...>  20050617 09:06:10

Hi@..., I'm not sure if my fit problem with gnuplot is an old hat. I have built a site that helps students to get results from physical experiments by the help of gnuplot. All is well but for a simple linear fit I get wrong parameters. My data are: 6.03e5 0.4 6.79e5 0.45 7.54e5 0.5 8.30e5 0.55 9.05e5 0.6 9.81e5 0.65 which are stored in a file 'lreg3.dat'. My gnuplot commands are: f(x) = a*x+b fit f(x) 'lreg3.dat' via a,b plot f(x), 'lreg3.dat' gnuplot comes up with a totally wrong regression line (i.e. a negative slope). If one scratches one data pair from list, the result is correct. I have read in 'help fit' that this misfit can occur if the magnitudes of both parameters a, b differ too much. This may be the case here. But a simple linear fit should always work. Or not? Is it true that the MarquardtLevenberg algorithm is used for all fits? Must I provide 'good' starting values for a, b to get a correct result? This would be very inconvenient here. Thank you very much for your help/comments. Regards, Eckard 
From: HansBernhard Broeker <broeker@ph...>  20050617 09:52:43

Eckard Specht wrote: > gnuplot comes up with a totally wrong regression line (i.e. a negative slope). > If one scratches one data pair from list, the result is correct. > > I have read in 'help fit' that this misfit can occur if the magnitudes of both > parameters a, b differ too much. This may be the case here. Not if the parameters are this different, the default startup values of 1.0 three orders of magnitude from the goal, and, which is the worst problem here, and the actual value for one of the fitted parameters (b) is zero, which makes it uncontrollable by the fit: fit m*x 'lreg3.dat' via m gives a very nice fit already: After 5 iterations the fit converged. final sum of squares of residuals : 2.48482e007 rel. change during last iteration : 6.69962e012 degrees of freedom (ndf) : 5 rms of residuals (stdfit) = sqrt(WSSR/ndf) : 0.000222927 variance of residuals (reduced chisquare) = WSSR/ndf : 4.96965e008 Final set of parameters Asymptotic Standard Error ======================= ========================== m = 6.62853e007 +/ 1.134e010 (0.01711%) So the actual result is b=0, which means the magnitude ratio of the parameters is *infinite*. That will indeed throw off the fit. > But a simple linear fit should always work. Or not? Not. It has a higher chance of success, but no guarantee. > Is it true that the MarquardtLevenberg algorithm is used for all fits? Yes. > Must I provide 'good' starting values for a, b to get a correct result? That, and a sensible model. Models in which parameters would fit zero won't work. 
From: Eckard Specht <specht@hy...>  20050617 12:44:50

Dear HansBernhard, thank you very much for the explanation. In all interactive gnuplot sessions, such problems can be recognized and avoided. But for 'batch' sessions this strategy is too restrictive. However, gnuplot is a wonderful tool. <a href=http://hydra.nat.unimagdeburg.de/praktikum/>Here</a>; is the "little helper". Best regards, Eckard 
Sign up for the SourceForge newsletter:
No, thanks