#621 Syntax extension 'fit ... using ... noerrors | errors [x][y][t][u][v]z'

fit (9)

With patch #585, fit will be able to handle errors in the independent variables x,y,t,u,v in addition to errors in the dependent variable z. Since the additional errors are (and have to be) all optional, the number of columns of the using spec can no longer be used as sole means to determine the type of fit, see Tables 1 and 3 below. But even with current syntax there exist two conflicts which lead to confusion and FAQs, see Table 2.

The attached patch therefore implements the following scheme to extend current syntax:

fit ... using ... noerrors | errors [x][y][t][u][v]z ...

The option "noerrors" indicates that no errors in dep. and indep. variables are given.
The option "errors" names the type of error columns given.
The order of the using specs is fixed and--for the most common cases--matches the corresponding plot/splot command. To mimic the syntax of the plot command even more, "xerror", "yerror" and "xyerror" are accepted as aliases for "errors x", "errors y", "errors xy", see Tables 4, 5, and 6. "zerror" is an alias for "errors z".
The current syntax is still supported for backwards compatibility.

Table 1: Allowed using specs according to current syntax; s is the error of the dep. variable z.

cols  spec
1     z
2     x:z
3     x:z:s
4     x:y:z:s
5     x:y:t:z:s
6     x:y:t:u:z:s
7     x:y:t:u:v:z:s

Table 2: Cases not handled by current syntax

cols  spec
2     z:s     ambiguity with x:z, use (0):z:s instead
3     x:y:z   ambiguity with x:z:s, use x:y:z:(1) instead

Table 3: With optional errors in the indep. variables, the total number of columns can no longer be used alone to determine the type of each column.

cols  spec
4     x:z:sx:sz
5-6   x:y:z[:sx][:sy]:sz
6-8   x:y:t:z[:sx][:sy][:st]:sz
7-10  x:y:t:u:z[:sx][:sy][:st][:su]:sz
8-12  x:y:t:u:v:z[:sx][:sy][:st][:su][:sv]:sz

Table 4: New syntax: Without weights

fit ... using x|z          noerror
fit ... using x:z|y        noerror
fit ... using x:y:z        noerror
fit ... using x:y:t:z      noerror
fit ... using x:y:t:u:v:z  noerror

Table 5: New syntax: With weights, z-errors only

fit ... using x|z:s        errors z | zerror | xerror
fit ... using x:y|z:s      errors z | zerror | yerror
fit ... using x:y:z:s      errors z | zerror
fit ... using x:y:t:u:v:z  errors z | zerror

Table 6: New sytax: With weights, indep. & dep. errors

fit ... using x:z:sx:sz           errors xz | xyerror
fit ... using x:y:z[:sx][:sy]:sz  errors [x][y]z
fit ... using x:y:t:u:v:z[:sx][:sy][:st][:su][:sv]:sz errors [x][y][t][u][v]z
1 Attachments


  • Ethan Merritt

    Ethan Merritt - 2013-05-22

    I don't think this is a real problem, but FYI I now get the following warnings when compiling fit.c. The are due to an earlier patch.

    fit.c:1045:18: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
    fit.c:1054:22: warning: format string is not a string literal (potentially insecure) [-Wformat-security]

  • Ethan Merritt

    Ethan Merritt - 2013-05-22

    But this one does look a real error, found by valgrind while running fit.dem.

    ==16237== Conditional jump or move depends on uninitialised value(s)
    ==16237== at 0x4C254D9: __GI_strlen (mc_replace_strmem.c:284)
    ==16237== by 0x435171: update (fit.c:1217)
    ==16237== by 0x42738E: update_command (command.c:2102)
    ==16237== by 0x423C0A: do_line (command.c:621)
    ==16237== by 0x45CB0B: load_file (misc.c:324)
    ==16237== by 0x4685B1: main (plot.c:626)

    And indeed, I can trap cases where the string passed to splitpath() contains random garbage. I think this results from calling update() with a NULL filename but I haven't traced it further. I suppose this came in with the fix for Bug #1156?

  • Bastian Märkisch

    Thanks for spotting those. Both are fixed now in CVS. Turns out that splitpath had a >10 year old FIXME concerning unknown buffer sizes and could be replaced by a call to gp_basename instead. Also, fprintf should really not have been called for just writing out a buffer without any formatting. Using fputs instead in now.

    Any comments or remarks about the proposed syntax? I do not insist on the details of it, but I like the fact that the same or similar using statements can be used by plot/splot and fit.

  • Bastian Märkisch

    gnuplot has now the possibility to use more than 5 independent variables in a fit. These can be renamed from their default names x, y, t, u, v with set dummy. This patch revises the proposed syntax to include errors for them accordingly:

    set dummy x1, x2
    fit ... u x1:sx1:x2:sx2:z:sz errors x1, x2, z

    Without patch #585, still only z-errors are allowed, of course. The abbreviations described above are still implemented.

  • Bastian Märkisch

    • labels: --> fit
  • Bastian Märkisch

    • status: open --> closed-accepted
  • Bastian Märkisch

    The revised syntax is now in CVS.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks