【问题标题】:Tell gnuplot to ignore functions it cannot fit告诉 gnuplot 忽略它不适合的函数
【发布时间】:2021-06-13 08:50:36
【问题描述】:

我正在尝试使用 gnuplot 将各种数据集拟合到某个拟合函数。我的一些数据文件无法拟合到函数(因为我的数据很嘈杂并且它们包含太多 NaN)并且一些拟合函数不起作用(如本问题所述:Troubles fitting exponential with gnuplot)因为我没有指定我的拟合参数的初始值。

当然,一种解决方案是为每个数据集仔细选择拟合参数,而不是尝试拟合明显不适合候选拟合函数的函数。但是,由于我只是想感受一下数据,并且由于我需要制作大约 1000 个图,有没有办法可以指定一些选项,例如“如果拟合失败,设置拟合函数 f(x)=0”?


注意:How to tell gnuplot to ignore non-converging fits 没有回答我的问题;当我运行 gnuplot (gnuplot-qt, Linux, v. 5.2 patchlevel 8) 时,对于我的一些数据集,它会失败并出现类似

的错误
Current data point
=========================
#               = 1 out of 3
x               = 5.93738        
z               = 5.97972        

Current set of parameters
=========================
a             = 5.93738        
b             = 25.7958        
c             = 73.596         

         "fitting.gp" line 68: Function evaluation yields NaN ("not a number")

gnuplot> 

(这里 a,b,c 是我的拟合参数,我通过输入 gnuplot > load "filename" 运行 gnuplot。


编辑:除了 fit 函数由于某些参数组合未定义而崩溃之外,有时拟合也会失败并出现错误“Singular matrix in Invert_RtR”。在所有这些情况下,我都想告诉 gnuplot 继续尝试拟合它可以拟合的数据集,并绘制生成的数据集(并在可用的情况下进行拟合)。

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    我认为没有 gnuplot 唯一的解决方案。

    源码中有如下注释(src/fit.c):

    /* FIXME: It would be nice to exit the "fit" command non-fatally, */
    /* so that the script who called it can recover and continue.     */
    /* int_error() makes that impossible.  But if we use int_warn()   */
    /* instead the program tries to continue _inside_ the fit, which  */
    /* generally then dies on some more serious error.                */
    

    这些行在我的 gnuplot 5.0.5 的源代码和当前源代码(5.4?)中。

    【讨论】:

      猜你喜欢
      • 2020-06-20
      • 1970-01-01
      • 2011-06-20
      • 1970-01-01
      • 2018-07-16
      • 1970-01-01
      • 2018-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多