为什么不是';t GNUPlot绘制一条趋势线';我的数据集中的点是否适合?

为什么不是';t GNUPlot绘制一条趋势线';我的数据集中的点是否适合?,gnuplot,Gnuplot,我有以下GNUPlot命令序列: $ cat bb.gnuplot set datafile separator "," set autoscale x set autoscale y set xdata time set timefmt "%Y%m%d" set format x "%Y%m%d" set key left top set grid m=1 b=1 f(x) = m*x + b fit f(x) "bb" using 1:2 via m,b plot "bb" using 1:

我有以下GNUPlot命令序列:

$ cat bb.gnuplot
set datafile separator ","
set autoscale x
set autoscale y
set xdata time
set timefmt "%Y%m%d"
set format x "%Y%m%d"
set key left top
set grid
m=1
b=1
f(x) = m*x + b
fit f(x) "bb" using 1:2 via m,b
plot "bb" using 1:2 title "filebeat-6.5.1", f(x) title "fit"
与此示例数据一起:

$ cat bb
20190416,0
20190417,0
20190418,0
20190419,0
20190420,0
20190423,0
20190424,0
20190425,0
20190426,0
20190509,0
20190510,72
20190511,62
20190512,63
20190513,108
20190514,78
20190515,66
20190516,59
20190517,86
20190518,57
20190519,57
20190520,62
20190521,78
20190522,95
20190523,104
20190524,22
20190525,128
20190526,96
20190527,125
20190528,129
20190529,152
20190530,160
20190531,148
20190601,136
20190602,178
20190603,198
20190604,148
20190605,140
20190606,142
20190607,171
20190608,205
20190609,174
20190610,198
20190611,208
20190612,205
20190613,13
我试图让GNUPlot在同一个图中画一条趋势线,但是我得到的这条线在我的图中的位置上对我来说没有意义

$  gnuplot < bb.gnuplot
iter      chisq       delta/lim  lambda   m             b
   0 1.0926745428e+20   0.00e+00  1.10e+09    1.000000e+00   1.000000e+00
   1 1.3194958855e+16  -8.28e+08  1.10e+08    1.098907e-02   1.000000e+00
   2 1.6307478323e+08  -8.09e+12  1.10e+07    1.279057e-06   1.000000e+00
   3 2.1025098835e+05  -7.75e+07  1.10e+06    5.819285e-08   1.000000e+00
   4 2.1025098815e+05  -9.56e-05  1.10e+05    5.819150e-08   1.000000e+00
iter      chisq       delta/lim  lambda   m             b

After 4 iterations the fit converged.
final sum of squares of residuals : 210251
rel. change during last iteration : -9.56318e-10

degrees of freedom    (FIT_NDF)                        : 43
rms of residuals      (FIT_STDFIT) = sqrt(WSSR/ndf)    : 69.9254
variance of residuals (reduced chisquare) = WSSR/ndf   : 4889.56

Final set of parameters            Asymptotic Standard Error
=======================            ==========================
m               = 5.81915e-08      +/- 7.064e-06    (1.214e+04%)
b               = 1                +/- 1.101e+04    (1.101e+06%)

correlation matrix of the fit parameters:
                m      b
m               1.000
b              -1.000  1.000
$gnuplot
结果图:

我希望这条线能穿过我的点,并在我提供的数据点中显示最佳拟合的线


我在这里遗漏了什么?

我在手册中找不到合适的部分,也无法很好地解释,但是 与以下人员交换您的功能:

f(x) = m*(x-strptime("%Y%m%d","20190509")) + b
我想这与偏移量/预定标有关,因为时间/日期数据是从1970年1月1日起以秒为单位在内部处理的。因此,今天,2019年6月13日约为15.6亿秒。你的时间跨度只有458万秒,这使得你很难找到合适的参数。如果我找到更好的解释,我会加上它(或者其他人可以更好地解释)

结果:


很有趣。我读了一些关于这方面的文章,尝试了一些方法,但从未尝试过这个特殊的例子。我认为这与fit函数本身有关。你的解决方案解决了我的问题,谢谢你。