lmdif
- sherpa.optmethods.optfcts.lmdif(fcn: Callable[[Sequence[float] | ndarray], tuple[float, ndarray]], x0: Sequence[float] | ndarray, xmin: Sequence[float] | ndarray, xmax: Sequence[float] | ndarray, ftol: SupportsFloat = np.float64(1.1920928955078125e-07), xtol: SupportsFloat = np.float64(1.1920928955078125e-07), gtol: SupportsFloat = np.float64(1.1920928955078125e-07), maxfev: int | None = None, epsfcn: SupportsFloat = np.float64(1.1920928955078125e-07), factor: float = 100.0, numcores: int = 1, verbose: int = 0) tuple[bool, ndarray, float, str, dict[str, Any]][source] [edit on github]
Levenberg-Marquardt optimization method.
The Levenberg-Marquardt method is an interface to the MINPACK subroutine lmdif to find the local minimum of nonlinear least squares functions of several variables by a modification of the Levenberg-Marquardt algorithm [1].
- Parameters:
- fcn
functionreference Returns the current statistic and per-bin statistic value when given the model parameters.
- x0, xmin, xmaxsequence
ofnumber The starting point, minimum, and maximum values for each parameter.
- ftol
number The function tolerance to terminate the search for the minimum; the default is FLT_EPSILON ~ 1.19209289551e-07, where FLT_EPSILON is the smallest number x such that
1.0 != 1.0 + x. The conditions are satisfied when both the actual and predicted relative reductions in the sum of squares are, at most, ftol.- xtol
number The relative error desired in the approximate solution; default is FLT_EPSILON ~ 1.19209289551e-07, where FLT_EPSILON is the smallest number x such that
1.0 != 1.0 + x. The conditions are satisfied when the relative error between two consecutive iterates is, at most,xtol.- gtol
number The orthogonality desired between the function vector and the columns of the jacobian; default is FLT_EPSILON ~ 1.19209289551e-07, where FLT_EPSILON is the smallest number x such that
1.0 != 1.0 + x. The conditions are satisfied when the cosine of the angle between fvec and any column of the jacobian is, at most,gtolin absolute value.- maxfev
intorNone The maximum number of function evaluations; the default value of
Nonemeans to use1024 * n, wherenis the number of free parameters.- epsfcn
number This is used in determining a suitable step length for the forward-difference approximation; default is FLT_EPSILON ~ 1.19209289551e-07, where FLT_EPSILON is the smallest number x such that
1.0 != 1.0 + x. This approximation assumes that the relative errors in the functions are of the order ofepsfcn. Ifepsfcnis less than the machine precision, it is assumed that the relative errors in the functions are of the order of the machine precision.- factor
int Used in determining the initial step bound; default is 100. The initial step bound is set to the product of
factorand the euclidean norm of diag*x if nonzero, or else to factor itself. In most cases,factorshould be from the interval (.1,100.).- numcores
int The number of CPU cores to use. The default is
1.- verbose: int
The amount of information to print during the fit. The default is
0, which means no output.
- fcn
References
[1]J.J. More, “The Levenberg Marquardt algorithm: implementation and theory,” in Lecture Notes in Mathematics 630: Numerical Analysis, G.A. Watson (Ed.), Springer-Verlag: Berlin, 1978, pp.105-116.