LMfit class
A general curve fitter using an implementation of Levenberg-Marquardt, based on https://github.com/reptillicus/jsfit. Usage: 1) call constructor, 2) call fit() NOTE: On http://statpages.info/nonlin.html you can fit an arbitrary function to arbitrary values, can be used for testing.
Constructors
- LMfit()
- Creates instance for accessing the methods, especially fit(). The other methods are helper function for fit().
Properties
- dof ↔ int
-
read / write
- epsilon ↔ double
-
read / write
-
fitterOptions
↔ Map<
String, List< String> > -
read / write
-
free
↔ List<
bool> -
read / write
-
initialParams
↔ List<
double> -
read / write
- iterationNumber ↔ int
-
read / write
- lambda ↔ double
-
read / write
- lambdaMinus ↔ double
-
read / write
- lambdaPlus ↔ double
-
read / write
- model ↔ FitFunction
-
read / write
- nfree ↔ int
-
read / write
- npars ↔ int
-
read / write
- numeric ↔ Numerics
-
read / write
- numJac ↔ int
-
read / write
- nvals ↔ int
-
read / write
-
options
↔ Map<
String, List< String> > -
read / write
-
params
↔ List<
double> -
read / write
- stopReason ↔ String
-
read / write
-
userWeights
↔ List<
double> -
read / write
- warnings ↔ String
-
read / write
- weightedFit ↔ bool
-
read / write
-
weights
↔ List<
double> -
read / write
-
xvals
↔ List<
double> -
read / write
-
yvals
↔ List<
double> -
read / write
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
chi2(
List< double> params) → double -
covar(
List< double> params) → List<List< double> > - If the minimisation uses the weighted least-squares function f_i = (Y(x, t_i) - y_i) / \sigma_i then the covariance matrix gives the statistical error on the best-fit parameters resulting from the Gaussian errors \sigma_i onthe underlying data y_i. This can be verified from the relation \delta f = J \delta c and the fact that the fluctuations in f from the data y_i are normalised by \sigma_i and so satisfy <\delta f \delta f^T> = I. For an unweighted least-squares function f_i = (Y(x, t_i) - y_i) t he covariance matrix above should be multiplied by the variance of the residuals about the best-fit \sigma^2 = \sum (y_i - Y(x,t_i))^2 / (n-p) to give the variance-covariance matrix \sigma^2 C . This estimates the statistical error on the best-fit parameters from the scatter of the underlying data.
-
diagonal(
List< List< arr) → List<double> >List< double> > - Passing in an m x n array, returns an array with only the main diagonals, all the rest are zeros
-
fit(
FitFunction userFitFunc, List< double> xvals, List<double> yvals, List<double> userWeights, List<double> initialParams, Map<String, List< options) → Map<String> >String, dynamic> -
Fits the data
xvals
with theiryvals
touserFitFunc
by iteratinginitialParams
. IfuserWeights
is not null, if must have the same length asxvals
andyvals
and applies the respective weight to each point. Otherwise, if null, alls weight are assumed to be 1.0. [...] -
fixParameters(
List< double> pars) → List<double> -
Fixes any parameters if they are going out of bounds
Generallly: List
parInfo = entry1, entry2, ...
. with: entry = "parname fixed/free limit1 limit2" Example: parInfo ="name1 fixed 0.5 1.0", "name2 free null null", ...
-
hessian(
List< double> params) → List<List< double> > - Returns H = 2 * Jt•J
-
init(
) → dynamic - init. variables
-
iterate(
List< double> params) → List<double> - Performs the minimization iteratively
-
jacobian(
List< double> params) → List<List< double> > - Calculate a numeric jacobian of the parameters. Jt•J is the approximation of the hessian
-
lmfit(
FitFunction fitFunction, List< double> xvals, List<double> yvals, List<double> initialPars, Map<String, List< fitOptions) → Future<String> >Map< String, List< >String> > - See fit function for a description of the parameters. This method is an async version of fit on the one hand, and returns the fit result stringified, on the other, rather than as dynamic values.
-
lmStep(
List< double> params, List<List< jac) → List<double> >double> - Levenberg-Marquardt step
-
parameterErrors(
) → List< double> - Returns the diagonal elements of the covariance matrix.
-
residuals(
List< double> params) → List<double> -
Calculates the residuals from the y-values and the model
params
r_i = 1/w_i * (y_i - model(x_i, params)) -
runFitter(
) → Map< String, dynamic> -
ssr(
List< double> params) → double -
Returns the sum of the squared residuals
params
. -
totalError(
) → double - Returns sig^2 = r(p)T * r(p) / (m -n) , m=# of obs, n = #of free params
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Properties
- CHI2 ↔ String
-
read / write
- CHI2RED ↔ String
-
read / write
- EPSILON → double
-
final
- FIT_ERROR → String
-
[...]
final
- FIT_OPT_TOLERANCE ↔ String
-
read / write
- INITIAL_PARAMS ↔ String
-
read / write
- ITERATIONS ↔ String
-
read / write
- MAX_ITERATIONS ↔ String
-
read / write
- PAR_INFO ↔ String
-
read / write
- PARAM_DELTA_CONVERGE ↔ String
-
read / write
- PARAMETER_ERRORS ↔ String
-
read / write
- PARAMS ↔ String
-
read / write
- STOP_REASON ↔ String
-
read / write
- TIME ↔ String
-
read / write