Hi,

I am having trouble implementing the most basic NLLS algorithm. I am following the example from here to every detail, yet my implementation keeps on diverging after 5 or so iterations. I will give an outline of what I'm doing below.

The example tries to fit the data to a Gaussian function, so the paramters for my model are $\displaystyle params = [A, x_{o}, \sigma]$.

Step 1

Make an initial guess of the paramters

$\displaystyle A^0 = 0.8$

$\displaystyle x_{o}^0 = 15$

$\displaystyle \sigma^0 = 4$

Step 2

Compute the values of the Jacobian using the current paramter values for each data point $\displaystyle i=1,2,...,m$

$\displaystyle J_{i,A} = \exp^{-((x - x_{0}^2)/2\sigma^2)}$

$\displaystyle J_{i,x_{0}} = A(x - x_{0})\exp^{-((x - x_{0}^2)/2\sigma^2)}/\sigma^2$

$\displaystyle J_{i,\sigma} = A(x - x_{0})\exp^{-((x - x_{0}^2)/2\sigma^2)}/\sigma^3$

Step 3

Compute the value of the current model approximation

$\displaystyle \hat{f} = A\exp^{-((x - x_{0}^2)/2\sigma^2)}$

Error between the data set and the current model

$\displaystyle \Delta\beta = y - \hat{f}$

If the error is large, update the paramter values as follows

$\displaystyle \Delta{params} = (J^T J)^{-1} (J^T \Delta\beta)$

$\displaystyle params^{k+1} = params^k + \Delta{params}$

Loop back toStep 2.

If my pseudo-code has confused things, please ignore it and just describe how such a basic NLLS algorithmshouldbe implemented.

Thanks!