gnuplot fit 是否有错误变量?

发布于 2025-01-20 18:35:06 字数 587 浏览 2 评论 0原文

我正在制作一个 C++ 代码,它打印 gnuplot 命令,以便更快地绘制不同的东西。代码已经将数据绘制为数据拟合,但现在我添加了一些标签,并且我想打印拟合方程,我的意思是这种形式的

f(x) = (a +/- Δa)* x + (b +/- Δb)

我有以下行用于打印它

set label 1 at screen 0.22, screen 0.75 sprintf('f(x) = %3.4f*x + %3.4f', a, b)

但是,如您所见,只有 a 和 b 值没有错误,我在想将其放入 sprintf 函数任何与错误相关的变量(FIT_something) 然后有类似

set label 1 at screen 0.22, screen 0.75 sprintf('f(x) = (%3.4f +/- %3.4f)*x + (%3.4f + %3.4f)', a, deltaa, b, deltab)

但我找不到那些,我的答案是:那些存在吗?如果答案是否定的,有没有办法进一步打印变量错误,只需将其显式写在行上?

感谢您的帮助

I'm making a c++ code which prints commands for gnuplot, in order to plot different things faster. The code plots the data already as the data fit as well, but now I'm adding some labels, and I want to print the fit equation, I mean something with this form

f(x) = (a +/- Δa)*x + (b +/- Δb)

I have the following line for printing it

set label 1 at screen 0.22, screen 0.75 sprintf('f(x) = %3.4f*x + %3.4f', a, b)

But, as you can see, there is only a and b values with no errors, I was thinking something like put there in the sprintf function any error related variables (FIT_something) and then have something like

set label 1 at screen 0.22, screen 0.75 sprintf('f(x) = (%3.4f +/- %3.4f)*x + (%3.4f + %3.4f)', a, deltaa, b, deltab)

But I can't find those, my answers are: does those exists? and if the answer is no, is there any way to print the variable errors further just writing it explicitly on the line?

Thanks for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呢古 2025-01-27 18:35:06

请阅读GNUPLOT文档的统计概述部分(help statistics_overview)。请记住,那里描述的警告,另请参阅文档的set fit for rorryvariables,我在下面提取:

 If the `errorvariables` option is turned on, the error of each fitted
 parameter computed by `fit` will be copied to a user-defined variable
 whose name is formed by appending "_err" to the name of the parameter
 itself.  This is useful mainly to put the parameter and its error onto
 a plot of the data and the fitted function, for reference, as in:

        set fit errorvariables
        fit f(x) 'datafile' using 1:2 via a, b
        print "error of a is:", a_err
        set label 1 sprintf("a=%6.2f +/- %6.2f", a, a_err)
        plot 'datafile' using 1:2, f(x)

 If the `errorscaling` option is specified, which is the default, the
 calculated parameter errors are scaled with the reduced chi square.  This is
 equivalent to providing data errors equal to the calculated standard
 deviation of the fit (FIT_STDFIT) resulting in a reduced chi square of one.

Please read the statistical overview section of the gnuplot documentation (help statistical_overview). Keeping in mind the caveats described there, see also the documentation for set fit errorvariables, which I extract below:

 If the `errorvariables` option is turned on, the error of each fitted
 parameter computed by `fit` will be copied to a user-defined variable
 whose name is formed by appending "_err" to the name of the parameter
 itself.  This is useful mainly to put the parameter and its error onto
 a plot of the data and the fitted function, for reference, as in:

        set fit errorvariables
        fit f(x) 'datafile' using 1:2 via a, b
        print "error of a is:", a_err
        set label 1 sprintf("a=%6.2f +/- %6.2f", a, a_err)
        plot 'datafile' using 1:2, f(x)

 If the `errorscaling` option is specified, which is the default, the
 calculated parameter errors are scaled with the reduced chi square.  This is
 equivalent to providing data errors equal to the calculated standard
 deviation of the fit (FIT_STDFIT) resulting in a reduced chi square of one.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文