fit method

Map<String, dynamic> fit (FitFunction userFitFunc, List<double> xvals, List<double> yvals, List<double> userWeights, List<double> initialParams, Map<String, List<String>> options)

Fits the data xvals with their yvals to userFitFunc by iterating initialParams. If userWeights is not null, if must have the same length as xvals and yvals and applies the respective weight to each point. Otherwise, if null, alls weight are assumed to be 1.0.

options allows one to override default values for the following map keys: MAX_ITERATIONS: 200, "ftol": 1e-10, // iterations terminate when reached "paramDeltaConverge": 0.0001, "parInfo": "name1 fixed 0.5 1.0", "name2 free null null" // example!

parInfo, if present in options: Sometimes we need to fix a parameter when fitting. Without modifying the underlying data model, we can hold parameters fixed during the fit.

Generallly: List parInfo =entry1, entry2, .... with: entry = "parname fixed/free limit1 limit2" 1 String entry in the list for each parameter! The number of entries must be the same as the number of parameter. The limits specify in which interval a parameter may vary. "null" means no limits imposed.

fit returns a map with the keys / values defined above. Note that the returned values are dynamic and need to be accessed correctly. The method lmfit of LMfit returns respective String conversions.

Implementation

Map<String, dynamic> fit(
    FitFunction userFitFunc,
    List<double> xvals,
    List<double> yvals,
    List<double> userWeights,
    List<double> initialParams,
    Map<String, List<String>> options) {
  this.model = userFitFunc;
  this.xvals = xvals;
  this.yvals = yvals;
  this.userWeights = userWeights;
  this.initialParams = initialParams;
  this.options = options;
  stopReason = null;
  warnings = "";
  init();
  return runFitter();
}