最小自乗法には fit を用いる。 最初に乗るべき関数を定義したあと、パラメータを計算させる。
> plot "planet081104_dat" > f(x) = a * sin(x) + b * cos(x) + c
使ったデータはこれ
> fit f(x) "planet081104_dat.dat" via a, b, c Iteration 0 WSSR : 1.09142e+19 delta(WSSR)/WSSR : 0 delta(WSSR) : 0 limit for stopping : 1e-05 lambda : 0.816497 initial set of free parameter values a = 1.66317e+09 b = -2.15942e+08 c = 5.04586e+08 **/ Iteration 1 WSSR : 1.09142e+19 delta(WSSR)/WSSR : -3.7529e-16 delta(WSSR) : -4096 limit for stopping : 1e-05 lambda : 8.16497 resultant parameter values a = 1.66317e+09 b = -2.15942e+08 c = 5.04586e+08 After 1 iterations the fit converged. final sum of squares of residuals : 1.09142e+19 rel. change during last iteration : -3.7529e-16 degrees of freedom (ndf) : 6 rms of residuals (stdfit) = sqrt(WSSR/ndf) : 1.34872e+09 variance of residuals (reduced chisquare) = WSSR/ndf : 1.81904e+18 Final set of parameters Asymptotic Standard Error ======================= ========================== a = 1.66317e+09 +/- 6.271e+08 (37.71%) b = -2.15942e+08 +/- 7.384e+08 (341.9%) c = 5.04586e+08 +/- 5.132e+08 (101.7%) correlation matrix of the fit parameters: a b c a 1.000 b -0.070 1.000 c 0.114 -0.475 1.000
最小自乗法のパラメータを計算したあとに
> replot f(x)