C:\>perl -le "sub f{@S=map{1+rand(0.1)}@S[0..3];return $S[3]*$_**3+$S[2]*$_**2+$S[1]*$_+$S[0]}for(-9..9){print $_.\" \".&f($_);}">a
C:\>
この後gnuplotで各変数が1.05に近ければうれしいんだな。
gnuplot> plot 'a', 'a' smooth csplines with lines,'a' smooth bezier,'a' using 1:2:(1.0) smooth acsplines
gnuplot> f(x)=d*x**3+c*x**2+b*x+a
gnuplot> fit f(x) 'a' via a,b,c,d
Final set of parameters Asymptotic Standard Error
======================= ==========================
a = -1.53336 +/- 1.965 (128.1%)
b = 0.818395 +/- 0.6023 (73.59%)
c = 1.30882 +/- 0.0489 (3.736%)
d = 1.0591 +/- 0.01028 (0.9706%)
correlation matrix of the fit parameters:
a b c d
a 1.000
b -0.000 1.000
c -0.747 0.000 1.000
d 0.000 -0.918 -0.000 1.000
gnuplot> plot 'a', 'a' smooth csplines with lines,'a' smooth bezier,'a' using 1:2:(1.0) smooth acsplines,f(x)
gnuplot>
ものすごく違うところがあるんだな。非常に不遜ながら標準偏差を考えれば一応あっていそうな感じがするんだな。ところでプロットの結果はやはり、ベジェ曲線やスプライン補間のほうが上手く実験の結果を表していることに気が付くんだな。各関数の形は単純な形なのにこれはかなりがっかりな結果なんだな。