2

I want to fit a function with a dataset using gnuplot.

I use a data set example, in the file "data":

1 2
5 4
6 5
7 8

If I do in gnuplot

>f(x) = a*x+b
>fit f(x) "data" via a,b

It works just good, (and with this example I get a≃0.855 and b≃0.687)

Now what I really want to do is to fit the function floor(a*x+b). So I tried exactly the same way

>f(x) = floor(a*x+b)
>fit f(x) "data" via a,b

And I get the output

 Iteration 0
 WSSR        : 8                 delta(WSSR)/WSSR   : 0
 delta(WSSR) : 0                 limit for stopping : 1e-005
 lambda   : 0

initial set of free parameter values

a               = 1
b               = 1
         Singular matrix in Givens()
         error during fit

Googling it didn't help me, I also tried to find if there was some contraindication using fit with floor but again I didn't find anything.

Has someone an idea?

Note : I use Gnuplot 4.6 patchlevel 0, built for Windows 32bit

4

1 に答える 1

4

最小二乗誤差関数が区分的に一定であるため、適合パラメーターに関して誤差の勾配を探すと、常にゼロになるという根本的な問題があります。

この例では、2 乗誤差の最小和は、0.85,1.5 付近の a,b の範囲で正確に 3 です。

(はるかに強力な) Mathematica は、勾配がゼロであるため、これが本当に最小かどうかを確認できないという警告とともに、結果 1,1 を返します。

于 2013-07-10T17:19:16.643 に答える