0

我经常使用 Octave 创建可以从实验室结果中绘制的数据。然后将该数据与 gnuplot 中的某些功能相匹配:

f1(x) = a * exp(-x*g);
fit f1(x) "c_1.dat" using 1:2:3 via a,g

这创建了一个fit.log

*******************************************************************************
Tue May  8 19:13:39 2012


FIT:    data read from "e_schwach.dat" using 1:2:3
        format = x:z:s
        #datapoints = 16
function used for fitting: schwach(x)
fitted parameters initialized with current variable values



 Iteration 0
 WSSR        : 12198.7           delta(WSSR)/WSSR   : 0
 delta(WSSR) : 0                 limit for stopping : 1e-05
 lambda   : 14.2423

initial set of free parameter values

mu2             = 1
omega2          = 1
Q2              = 1

After 70 iterations the fit converged.
final sum of squares of residuals : 46.0269
rel. change during last iteration : -2.66463e-06

degrees of freedom    (FIT_NDF)                        : 13
rms of residuals      (FIT_STDFIT) = sqrt(WSSR/ndf)    : 1.88163
variance of residuals (reduced chisquare) = WSSR/ndf   : 3.54053

Final set of parameters            Asymptotic Standard Error
=======================            ==========================

mu2             = 0.120774         +/- 0.003851     (3.188%)
omega2          = 0.531482         +/- 0.0006112    (0.115%)
Q2              = 17.6593          +/- 0.7416       (4.199%)


correlation matrix of the fit parameters:

               mu2    omega2 Q2     
mu2             1.000 
omega2         -0.139  1.000 
Q2             -0.915  0.117  1.000 

有什么方法可以将参数及其错误返回 Octave?我的意思是我可以编写一个 Python 程序来解析它,但我希望避免这种情况。

更新

这个问题不再适用于我,因为我现在在我的实验室工作中使用 Python 和 matplotlib,它可以通过一个程序完成所有这些工作。如果其他人有同样的问题,我会留下这个问题。

4

1 回答 1

5

I don't know much about the gnuplot-Octave interface, but what can make your (parsing) life easier is you can:

set fit errorvariables
fit a*x+g via a,g
set print "fit_parameters.txt"
print a,a_err
print g,g_err
set print

Now your variables and their respective errors are in the file "fit_parameters.txt" with no parsing needed from python.

from the documentation on fit:

If gnuplot was built with this option, and you activated it using set fit errorvariables, the error for each fitted parameter will be stored in a variable named like the parameter, but with _err appended. Thus the errors can be used as input for further computations.

于 2012-05-27T11:58:39.283 回答