fit to time series using Gnuplot

别说谁变了你拦得住时间么 提交于 2019-12-04 13:44:07

Indeed, gnuplot's fitting mechanism works fine for time-data. You must only pay attention to some details.

In general, a linear fit through two data points can be solved exactly. But gnuplot does generally a nonlinear fit, so the initial values are important.

The effective x-value used for the line is given in seconds. Using an initial value of b = 1e-8 works fine here:

set timefmt "%Y-%m-%d"
set xdata time
set format x "%Y-%m-%d"
f(x)=a+b*x
a = 1
b = 1e-8
fit f(x) "model_fit.dat" u 10:($2==2?$4:1/0) via a,b

plot "model_fit.dat" u 10:($2==2?$4:1/0) lt 1 pt 7 title 'data',\
     f(x) w l lt 1 title 'fit'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!