# FindFit algorithm?

Does anyone know how to program a mathematica algorithm that does the same thing that FindFit does? Is there documentation of it somewhere? I assume it is a least squares algorithm but with very generalized arguments. I ask because I’m trying to use ‘weighted’ least squares and it basically involves just one more factor.

=================

1

NonlinearModelFit[] can handle weighted nonlinear least squares.
– J. M.♦
Oct 31 ’15 at 14:04

=================

1

=================

Fit works using singular value decomposition. FindFit uses the same method for the linear least-squares case, the Levenbergâ€“Marquardt method for nonlinear least-squares, and general FindMinimum methods for other norms.

– source

NonlinearModelFit allows fitting of weighted data, as J.M. commented

Edit:

The best fit parameters are a property of the model:

p = Table[Prime[x], {x, 20}];

nlm = NonlinearModelFit[p, a x Log[b + c x], {a, b, c}, x];
nlm[“BestFitParameters”]

{a -> 1.42076, b -> 1.65558, c -> 0.534645}

How do I get the list parameters from NonlinearModel? FindFit outputs such a thing
– minusatwelfth
Oct 31 ’15 at 16:56

@minusatwelfth see my edit.
– paw
Oct 31 ’15 at 17:12

@minus, it’s all in the docs, if you’d look for them.
– J. M.♦
Nov 1 ’15 at 2:04