Menu

#1594 yrange is ignored by fitting routine

None
closed-fixed
fit (6)
2015-06-07
2015-04-15
Anonymous
No

I am running on Fedora 19.
Until recently I used gnuplot 4.6 to fit curves.
Specifically something of the form
deltax = 1
deltay = 0.1
f(x) = mx+c
fit [-deltax:deltax] f(x) "file.txt" u 1:2 via m,c
g(x) = n
x+d
fit [][-deltay:deltay] g(x) "file.txt" u 1:2 via n,d

Where the fitted data resembled a diode curve (L-shaped).
So both fits get the slope of the "L" where it crosses one of the axes.

I upgraded to gnuplot 5.0 patchlevel 0, and it stopped working.
In the manual I cannot find any changed referencing "fit" or "plot ranges", so I assume this change is not intended.

In any minimal example I came up with, the yrange restrictions have no effect. (when fitting, plotting works fine)
Is this change intended?
If so, where is it documented, and How can I get my fits working again?

Discussion

  • Karl Ratzsch

    Karl Ratzsch - 2015-04-15

    Any y range, either given inline or via "set yrange", is ignored by "fit". That certainly is a bug. gp5.1 behaves the same.

    Before it gets fixed, you can filter the data through the using specs instead:

    fit g(x) "file.txt" u 1:(abs($2)>deltay?NaN:$2) via n,d
    
     
  • Karl Ratzsch

    Karl Ratzsch - 2015-05-11
    • labels: --> fit
    • summary: Undocumented change of behaviour of fit ranges? --> yrange is ignored by fitting routine
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2015-06-05

    The function range is now always "z".
    So you can use

    set zrange [-deltay:deltay]

    The documentation could be clearer on this point, although it does state and show examples that if there is only 1 independent variable and 1 dependent variable they are 'x' and 'z'. Where would you like to see the clarification go, exactly?

    That doesn't seem to be allowed for in-line ranges, however.

    gnuplot> fit [][][-delty:deltay] ...
    line 17: Too many range-specs for a 1-variable fit

    I strongly recommend against using in-line ranges anyhow, so this does not seem to me like sufficient reason to delay the release of patchlevel 1.

     
    • Karl Ratzsch

      Karl Ratzsch - 2015-06-05

      I notice "set yrange" also doesn't influence a fit with one independent variable in ver4.6. "set zrange" does, though, so that part is in fact unchanged.

      I guess the best place for a clarification is at the begining of the section on "Fit":
      "..analogous to plot; see plot ranges (p. 92). Ranges applied via "set _range" also apply, please note that the dependent variable is always "z" (see below)."
      I can upload a patch tomorrow.

      Why should the zrange come as a third inline range for a 2D fit?

      I quite see why you don't like inline ranges, but this regression might go unnoticed for a long time, given circumstances. That could turn out ugly for some people, probably.

      Btw. giving three inline ranges for a 3D fit also doesn't work in v5.0, but does in 4.6.

      fit [][][0:10] a*x + b*y "-" us 1:2:3:(1) via a,b
      1 2 3
      2 3 5
      3 4 7
      4 5 9
      5 6 123
      e
      
       
  • Hans-Bernhard Broeker

    This appears to have been broken since about two years ago: 2013-06-27. The move to increase the maximum on the number of allowed independent variables in a fit broke the link between the y range (including inline ranges) and the dependent variable range of a 1-variable fit. Now it will use the z range instead. But it doesn't accept setting that in-line.

    I will submit a fix for this to both HEAD and the 5.0 branch.

     
  • Karl Ratzsch

    Karl Ratzsch - 2015-06-06

    Here's a patch for gnuplot.doc.

    The other one fixes the error message displayed if someone tries to give a variable name to the dependent variable

    fit [][z=0:10] f(x) $data us 1:2 via ...
    

    , it still used "y".

    Btw., Ethan, the range specifiers in "fit" address variable ranges, like the new sampling ranges in "plot", but unlike the inline axis range specifiers, that you so rightfully disapprove of. Maybe the use of "set _range" for fitting should in fact be deprecated/discontinued in the future?

     
  • Hans-Bernhard Broeker

    • status: open --> closed-fixed
    • assigned_to: Hans-Bernhard Broeker
     
  • Hans-Bernhard Broeker

    Fixed in both HEAD and 5.0 branch

     

Log in to post a comment.