I'm trying to fit my data to this curve:
f(x) = b + n*exp(-x/u)
fit f(x) "data1" using 2:3 via b,n,u
I get this fit which is not close to theory:
Then I use initial parameters from theory and without recomputing the fit I get a much nicer result.
If I recompute the fit, it ignores my initial parameters after the first iteration and goes back to the first result.
I try a couple of things. I reduce the FIT_LIMIT by 20 orders of magnitude but it doesn't change anything. I also bias the data with errors so that I put much more weight on the first few data points and then I get a somewhat better fit but it's still bad.
This is the output:
Questions:
It's not clear to me whether the issue is mathematical or whether GNUplot is just doing things wrong by stopping at some local minimum or hitting some limit or some such thing. I've forgotten all about how chi-squared fit works.
Is there some way to get a better automatic fit, ideally before resolving to include errors in my data?
Two ideas:
You seem to have a considerable number of data points around (0,0) which look like artifacts and probably affect your fit.
Try fitting in the logarithmic domain, i.e.:
f(x) = b + n*exp(-x/u)
fit log(f(x)) "data1" using 2:(log($3)) via b,n,u
This trick usually works if the large values dominate the fit – as their deviations from the fitted curve weigh less in the logarithmic domain. This does not seem to be the case for you yet, but may be after you address point 1.