gnuplot> f(x)=a2*sin(omega*x+phi)+d2This is the function described in the previous post, in gnuplot syntax. Now, you can try and fit the data to the function. The total data set isn't a consistent wave form so I'm going to reduce the data set to points between 150 and 250.gnuplot> fit [150:250] f(x) "spin.dat" using 0:7 via a2,omega,phi,d2The above instructs gnuplot to execute an iterative process, attempting to derive the values for a2, omega, phi, and d2 in the function defined as f(x). Gnuplot will output the results in various stages of the process. The most critical results are the final ones of course, which I reprint here:You may notice two things:Final set of parameters Asymptotic Standard Error ======================= ========================== a2 = 0.774445 +/- 11.02 (1423%) omega = 0.973404 +/- 0.4104 (42.16%) phi = 6.881 +/- 82.27 (1196%) d2 = -66.2102 +/- 6.535 (9.871%)
- The equation parameters are quite different from those that I posted previously, and
- The standard error percentage of the parameters is quite high (even the lowest, 9% is pretty significant).
gnuplot> a2=93.5
gnuplot> d2=-75.6
gnuplot> omega=1/4.6
gnuplot> phi=-6
gnuplot> fit [150:250] f(x) "spin.dat" using 0:7 via a2,omega,phi,d2Which ultimately resulted in:Final set of parameters Asymptotic Standard Error ======================= ========================== a2 = 90.8588 +/- 1.735 (1.909%) omega = 0.220797 +/- 0.0006131 (0.2777%) phi = -8.0615 +/- 0.1239 (1.537%) d2 = -74.2817 +/- 1.185 (1.596%)
gnuplot> plot "spin.dat" using 7 axes x1y1 t "mag y" with lines, a2*sin(omega*x+phi)+d2
Which looks like a fairly good fit, with less than 2% error. A better fit could be made using equations with more independent variables, however, gnuplot's curve fit feature is limited to 5, of which the above already was using 4. I don't think there is much chance of refining this estimation any further using the fit feature of gnuplot.

No comments:
Post a Comment