As I understand, it is intended that plot 'data' and fit f(x) 'data' handle the using directive the same way. That is the case with simple statements such as
plot 'data' using 1:5
I ran into problems with the following
plot 'data.txt' using 1:5:2:6 with xyerrorbars
f(x)=2*d*x
fit f(x) 'data' using 1:5:2:6 via d
The plot looks ok, but the fit is way off. If i use just the y delta, as in using 1:5:6, i get an approximately right result but i would be discarding some of the data that i have. Also, the fitting just the data points (using 1:5) produces wrong results. My data is here, just for reference and your experiments:
Your problem is that while plot and fit do indeed treat 'using' etc. identically, that does not mean they must do the thing with the data once read. fit simply has no equivalent to plot's xyerrorbarrs style, so it cannot treat the data the same way your plot command does. Four using specifiers in a 'fit' command turn it into a 3D fit. Please consult more of "help fit" to understand what your commands actually do.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2011-11-20
Hmm, the original post was likely a bit misleading. I have read the documentation and done several hours worth of googling, but i didn't find a way to make a fit that takes into account uncertainties in both directions. The only logical extension to that three column form (using 1:5:6) was what i tried, but that didn't work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, like I said, the thing you were looking for could not be found because it doesn't exist. There really is no sane way for a non-linear, generic least-squares fitting algorithm to take into account uncertainties in the x direction -- the algorithm itself doesn't even recognize the eixstence of x values, as such. For all 'fit' really wants to know, the input consists of a sequence of triplets:
* value
* error
* function of several parameters
Fits where these many separate functions are actually the same function with an additional argument 'x', evaluated at different 'x' values, are a special case of that. Errors in those 'x' values don't enter the picture in any way, nor can they be forced into it in any reasonable way.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2011-11-20
nor can they be forced into it in any reasonable way.
One can always invert the function an fit that.
In this case it is still a linear problem and I can do a fit using 5:1:2 and deduce the parameter d from that. That way i get to use the larger error estimates from x.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No, one can't always do that. Linear fits are a very special case. 'fit' is for the general case.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2011-11-20
Every continuous function on the real line has partial inverses, one between every two local extrema. So, in principle, it is possible, though it will become a bit more complicated when there are only partial inverses. This time there are no local extrema, so there is a true inverse for the whole function. Linearity has nothing to do with it. For a non-linear example, consider exp(x) and log(x).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2011-11-22
Besides, i see no reason why one cannot put 2d normal distributions around those (y,x) pairs and try to find the curve with maximum likelihood. I admit that I'm not a real statistician, but to me it seems simple enough.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As I understand, it is intended that plot 'data' and fit f(x) 'data' handle the using directive the same way. That is the case with simple statements such as
I ran into problems with the following
The plot looks ok, but the fit is way off. If i use just the y delta, as in using 1:5:6, i get an approximately right result but i would be discarding some of the data that i have. Also, the fitting just the data points (using 1:5) produces wrong results. My data is here, just for reference and your experiments:
How do i fix it?
Whoops, the file is called data.txt and I obviously did the fit with that, not just 'data' which would not have worked. That is not the issue here.
Your problem is that while plot and fit do indeed treat 'using' etc. identically, that does not mean they must do the thing with the data once read. fit simply has no equivalent to plot's xyerrorbarrs style, so it cannot treat the data the same way your plot command does. Four using specifiers in a 'fit' command turn it into a 3D fit. Please consult more of "help fit" to understand what your commands actually do.
Hmm, the original post was likely a bit misleading. I have read the documentation and done several hours worth of googling, but i didn't find a way to make a fit that takes into account uncertainties in both directions. The only logical extension to that three column form (using 1:5:6) was what i tried, but that didn't work.
Well, like I said, the thing you were looking for could not be found because it doesn't exist. There really is no sane way for a non-linear, generic least-squares fitting algorithm to take into account uncertainties in the x direction -- the algorithm itself doesn't even recognize the eixstence of x values, as such. For all 'fit' really wants to know, the input consists of a sequence of triplets:
* value
* error
* function of several parameters
Fits where these many separate functions are actually the same function with an additional argument 'x', evaluated at different 'x' values, are a special case of that. Errors in those 'x' values don't enter the picture in any way, nor can they be forced into it in any reasonable way.
One can always invert the function an fit that.
In this case it is still a linear problem and I can do a fit using 5:1:2 and deduce the parameter d from that. That way i get to use the larger error estimates from x.
No, one can't always do that. Linear fits are a very special case. 'fit' is for the general case.
Every continuous function on the real line has partial inverses, one between every two local extrema. So, in principle, it is possible, though it will become a bit more complicated when there are only partial inverses. This time there are no local extrema, so there is a true inverse for the whole function. Linearity has nothing to do with it. For a non-linear example, consider exp(x) and log(x).
Besides, i see no reason why one cannot put 2d normal distributions around those (y,x) pairs and try to find the curve with maximum likelihood. I admit that I'm not a real statistician, but to me it seems simple enough.
You are quite correct that one can use maximum likelihood to account for errors on both x and y. Unfortunately, that isn't implemented in gnuplot.