Fit constant term in LM algorithm

I'm using the Levenberg-Marquardt algorithm to fit my data with a Gaussian function: $$f(x)=a\cdot e^{-\frac{(x-c)^2}{2\sigma^2}}+f_0$$ $a$, $c$, $\sigma$ and $f_0$ are the fitting parameters. The algorithm correctly computes $a$, $c$ and $\sigma$. Given that $$\frac{\partial f}{\partial f_0} = 1$$ and a $\delta \vec{x}$ solution of the least-squared problem: $$\delta \vec{x} = (\vec{J}\vec{J}^T)^{-1} \cdot\vec{J}f$$ I get that $\delta \vec{x}$ is not sensible to any change in $f_0$; so it says nothing on what to do to minimize the $\chi^2$.

What am I missing? Do I have to switch to minimizing the $\chi^2$ function with the Brent algorithm (though it kinda spells trouble to me) to obtain the right known term or is there a more effective way to get there?

Or am I making it a lot harder than it is?

• $\frac{\partial f}{\partial f_{0}}$ is non-zero and hence, shows there is some effect in the objective on changing $f_{0}$. I don't see why this is not working directly. You could always, as suggested, solve for the minimum $f_{0}$ through an outer line-search. – gpavanb Jul 20 '17 at 1:10
• I will follow your suggestion. It doesn't change one bit: that is what is puzzling to me – GoGoLander Jul 20 '17 at 11:34
• How is $\lambda$ (the damping prefactor for identity matrix) varying in your LM implementation. – gpavanb Jul 20 '17 at 18:24
• $\lambda = 10^{-3}$ at start. If the test point $P_1$ is a better point than the current $P_0$, i.e. $\chi^2(P_1) < \chi^2(P_0)$, I divide $\lambda$ by 10; I multiply it by 5 if it is not. Press et al. suggest a factor 10 in Numerical Recipes but I don't want the algorithm to get another point too far from the current best guess and to avoid the overflow as much as possible. It should be good enough, Isn't it? – GoGoLander Jul 20 '17 at 21:38