Ubuntu 如何对日期数据执行指数拟合?

Ubuntu 如何对日期数据执行指数拟合?,ubuntu,gnuplot,Ubuntu,Gnuplot,我有一些这种格式的数据: 0,1/19/20 0,1/20/20 0,1/21/20 1,1/22/20 6,1/23/20 7,1/24/20 11,1/25/20 15,1/26/20 28,1/27/20 38,1/28/20 我想画一条指数曲线来拟合它。 这就是我正在尝试的: set datafile separator "," set terminal svg enhance background rgb "white" set timefmt "%m/%d/%y" set xdat

我有一些这种格式的数据:

0,1/19/20
0,1/20/20
0,1/21/20
1,1/22/20
6,1/23/20
7,1/24/20
11,1/25/20
15,1/26/20
28,1/27/20
38,1/28/20
我想画一条指数曲线来拟合它。 这就是我正在尝试的:

set datafile separator ","
set terminal svg enhance background rgb "white"
set timefmt "%m/%d/%y"
set xdata time
set format x "%m/%d/%y"
f(x)=a*exp(x*b)
a=1
b=0.00000000001
fit f(x) "test.dat" using 2:1 via a,b
plot "test.dat" using 2:1, f(x)
但我得到的是:

输出:

iter      chisq       delta/lim  lambda   a             b            
   0 2.4518484242e+03   0.00e+00  7.18e-01    1.000000e+00   1.000000e-11
   1 1.0605090928e+03  -1.31e+05  7.18e-02    1.397524e+01   1.205276e-11
   2 1.0548499551e+03  -5.36e+02  7.18e-03    1.473392e+01   1.761422e-11
   * 1.1929533566e+03   1.16e+04  7.18e-02    5.600970e+00   4.096647e-10
   3 1.0548479644e+03  -1.89e-01  7.18e-03    1.463642e+01   2.152072e-11
iter      chisq       delta/lim  lambda   a             b            

After 3 iterations the fit converged.
final sum of squares of residuals : 1054.85
rel. change during last iteration : -1.88724e-06

degrees of freedom    (FIT_NDF)                        : 5
rms of residuals      (FIT_STDFIT) = sqrt(WSSR/ndf)    : 14.5248
variance of residuals (reduced chisquare) = WSSR/ndf   : 210.97

Final set of parameters            Asymptotic Standard Error
=======================            ==========================
a               = 14.6364          +/- 4.851e+04    (3.315e+05%)
b               = 2.15207e-11      +/- 2.098e-06    (9.749e+06%)

correlation matrix of the fit parameters:
                a      b      
a               1.000 
b              -1.000  1.000 

另一种情况(数据格式相同,命令相同):

绘图:

输出:

iter      chisq       delta/lim  lambda   a             b            
   0 3.1449068545e+15   0.00e+00  8.39e+07    1.000000e+00   1.000000e-08
   1 4.3978813150e+14  -6.15e+05  8.39e+06    9.961173e-01   9.380902e-09
   2 6.0443707833e+13  -6.28e+05  8.39e+05    9.921770e-01   8.756643e-09
   3 8.2818940310e+12  -6.30e+05  8.39e+04    9.880292e-01   8.132279e-09
   4 1.1307879559e+12  -6.32e+05  8.39e+03    9.783880e-01   7.512240e-09
   5 1.4643178088e+11  -6.72e+05  8.39e+02    7.869411e-01   7.011825e-09
   ...
 223 4.3503512818e+08  -6.75e-01  8.39e+03    7.898096e-31   4.829813e-08
iter      chisq       delta/lim  lambda   a             b            

After 223 iterations the fit converged.
final sum of squares of residuals : 4.35035e+08
rel. change during last iteration : -6.75096e-06

degrees of freedom    (FIT_NDF)                        : 55
rms of residuals      (FIT_STDFIT) = sqrt(WSSR/ndf)    : 2812.42
variance of residuals (reduced chisquare) = WSSR/ndf   : 7.90973e+06

Final set of parameters            Asymptotic Standard Error
=======================            ==========================
a               = 7.8981e-31       +/- 1.236e-30    (0%)
b               = 4.82981e-08      +/- 2.01e-07     (416.2%)

correlation matrix of the fit parameters:
                a      b      
a               1.000 
b              -1.000  1.000 
line 0: warning: Too many axis ticks requested (>6e+04)
line 0: warning: Too many axis ticks requested (>6e+04)
我怀疑我没有为拟合曲线选择正确的初始参数,但我使用了很多值(尤其是b),有时我会在real()中得到未知类型

我读过,在处理日期时,
x
取本世纪初的秒数。如果是这样的话,那么我不知道如何用这个数字进行正确的操作。如果可能的话,我还想去掉所有的xtic和y为0的点。
有人能指出我做错了什么吗?可能我没有使用正确的拟合功能?

时间数据从1970年1月1日00:00:00开始在内部以秒为单位处理。检查帮助时间/日期。因此,您需要按开始日期移动函数
f(x)
,并给出合理的开始值,尤其是
b

代码:

### exponential fit of time data
reset session

$Data <<EOD
0,1/19/20
0,1/20/20
0,1/21/20
1,1/22/20
6,1/23/20
7,1/24/20
11,1/25/20
15,1/26/20
28,1/27/20
38,1/28/20
EOD

set datafile separator comma

myTimeFmt = "%m/%d/%y"
set format x "%m/%d" time

# get the start date
set table $Dummy
    plot $Data u (Start=timecolumn(2,myTimeFmt)) index 0 every ::0:0:0:0 w table
unset table

b=1e8    # reasonable startvalue for fitting
f(x) = a*exp((x-Start)/b*log(2))+c
set fit nolog
fit f(x) $Data u (timecolumn(2,myTimeFmt)):1 via a,b,c

End = strptime(myTimeFmt,"2/11/20")
set xrange[Start:End]
set yrange[0.5:]
set logscale y
set grid xtics, ytics
set key top left

set label 1 at graph 0.01, graph 0.85 sprintf("Doubling every: %.2f days",b/84600.)

plot $Data u (timecolumn(2,myTimeFmt)):1 w lp pt 7 lc rgb "blue" ti "Data", \
     f(x) w l lc rgb "red" ti "Fit"
### end of code 
时间数据的指数拟合 重置会话
$Data时间数据从1970年1月1日00:00:00开始以秒的形式在内部处理。检查帮助时间/日期。因此,您需要按开始日期移动函数
f(x)
,并给出合理的开始值,尤其是
b

代码:

### exponential fit of time data
reset session

$Data <<EOD
0,1/19/20
0,1/20/20
0,1/21/20
1,1/22/20
6,1/23/20
7,1/24/20
11,1/25/20
15,1/26/20
28,1/27/20
38,1/28/20
EOD

set datafile separator comma

myTimeFmt = "%m/%d/%y"
set format x "%m/%d" time

# get the start date
set table $Dummy
    plot $Data u (Start=timecolumn(2,myTimeFmt)) index 0 every ::0:0:0:0 w table
unset table

b=1e8    # reasonable startvalue for fitting
f(x) = a*exp((x-Start)/b*log(2))+c
set fit nolog
fit f(x) $Data u (timecolumn(2,myTimeFmt)):1 via a,b,c

End = strptime(myTimeFmt,"2/11/20")
set xrange[Start:End]
set yrange[0.5:]
set logscale y
set grid xtics, ytics
set key top left

set label 1 at graph 0.01, graph 0.85 sprintf("Doubling every: %.2f days",b/84600.)

plot $Data u (timecolumn(2,myTimeFmt)):1 w lp pt 7 lc rgb "blue" ti "Data", \
     f(x) w l lc rgb "red" ti "Fit"
### end of code 
时间数据的指数拟合 重置会话
$Data啊,我明白了,我把时间搞砸了。非常感谢,这很有效!啊,我明白了,我把时间搞砸了。非常感谢,这很有效!