LMFIT and Numerical Simulation

Skip to first unread message

adam najem

Feb 22, 2024, 9:58:17 AMFeb 22
to lmfit-py

I am currently using the LMFIT algorithm with the LEASTSQ method to estimate some parameters for my numerical model. The fitting function operates by taking these parameters as input, modifying the simulation script accordingly, and initiating the simulation. (So the model is not explicitly given, I instead use a subprocess). Subsequently, it retrieves the numerical results from the simulation. The error array is then computed by comparing these numerical results with the experimental data.

What I don't understand is the calculation of the Jacobian matrix to determine the parameter increment. Per incriment, ONLY ONE simulation is being launched after each iteration to compute the error function using the updated parameter set, I'm curious about the specific method employed to compute the Jacobian matrix within this iterative process. Thank you,

Matt Newville

Feb 22, 2024, 9:06:12 PMFeb 22
to lmfi...@googlegroups.com
Hi Adam, 

By default,  each iteration for the `leastsq` method will call your objective or model function Nvariables+1 time to construct the finite-difference Jacobian and use that to predict the next set of values for the variables.  The step size taken for each value will be small - typically the value will be changed by a factor of 1+1.e-5.  Well, unless the value is very close to zero).  That step size may vary during the call, and if bounds are placed on some of the values.  There will likely be a few calls to your objective or model function in the beginning and maybe a few additional calls at the end.

Lmfit does not care what your objective or model function does or how long it takes to run; it only cares about the value it returns. 

You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfit-py+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/a98d065e-d44e-4353-873d-d5c4488dee96n%40googlegroups.com.

Reply all
Reply to author
0 new messages