How to get a better exponential fit using GNUplot?
<p>I'm trying to fit my data to this curve:</p>
<pre><code>f(x) = b + n*exp(-x/u)
fit f(x) &quot;data1&quot; using 2:3 via b,n,u
</code></pre>
<p>I get this fit which is not close to theory:</p>
<p><a href="https://i.stack.imgur.com/mFQLq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mFQLq.png" alt="enter image description here" /></a></p>
<p>Then I use initial parameters from theory and without recomputing the fit I get a much nicer result.</p>
<p>If I recompute the fit, it ignores my initial parameters after the first iteration and goes back to the first result.</p>
<p>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.</p>
<p>This is the output:</p>
<p><a href="https://i.stack.imgur.com/WMATU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WMATU.png" alt="enter image description here" /></a></p>
<p>Questions:</p>
<ol>
<li><p>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.</p>
</li>
<li><p>Is there some way to get a better automatic fit, ideally before resolving to include errors in my data?</p>
</li>
</ol>