init method

dynamic init ()

init. variables

Implementation

init() {
//      //print("yy2000=${numeric}");
  //print("yy2001=${numeric.epsilon}");
  //the smallest possible delta due to floating point precision.
  epsilon = EPSILON * 100;
//      //print("yy2002=${epsilon"]}");
//      //print("yy2003=${data}");
  //store the x values on self
  //number of observations
  nvals = xvals.length;
  //the weights array, if it exists. If not, set all points to have unit weights
  if (userWeights == null || userWeights.length != nvals) {
    weightedFit = false;
    weights = List(nvals);
    weights.fillRange(0, nvals, 1.0);
  } else {
    weights = userWeights;
    weightedFit = true;
  }

  //store the parameters on self
  params = initialParams;
  npars = initialParams.length;
  //An array indicating if the parameter is free of fixed
  free = List(npars);
  free.fillRange(0, npars, true);
  //the number of free parameters
  nfree = params.length;
  //the number of degrees of freedom
  dof = nvals - nfree;

  //the l-m damping parameter
  lambda = 0.1;
  //the lambda up paramaeter
  lambdaPlus = 5.0;
  //the lambda decrease parameter
  lambdaMinus = 0.5;
  //stopping reason
  stopReason = null;
  //number of jac calcs
  numJac = 0;
  //the default fitter options
  Map<String, List<String>> defaultOptions = {
    MAX_ITERATIONS: ["200"],
    "debug": ["false"],
    FIT_OPT_TOLERANCE: ["1e-10"],
    "chart": ["false"],
    "paramDeltaConverge": ["0.0001"],
  };

  if (xvals.length != yvals.length) {
    throw 'x and y arrays are different lengths';
  }

  if (xvals.length != weights.length) {
    throw 'x and weights arrays are different lengths';
  }

  //merge in any options that are passed in into the defaultOptions object
  fitterOptions = defaultOptions;
  for (String key in options.keys) {
    if (options[key] != null) {
      fitterOptions[key] = options[key];
    }
  }

  //Make sure that parInfo, if it came through, is the same length as the
  //parameter array:
  // parInfo = ["name1 fixed limit1 limit2", "name2 free limit1 limit2", ...]
  List<String> parInfo = fitterOptions["parInfo"];

  nfree = npars;
  if (parInfo != null) {
    if (parInfo.length != npars) {
      throw 'parInfo and params must be SAME length';
    }

    String entry;
    // parameter name not evaluated, expect correct sequence of entries.
    for (int i = 0; i < npars; i++) {
      entry = parInfo[i];
      if (entry == null) {
        continue;
      }
      if (entry.split(" ")[1] == "fixed") {
        free[i] = false;
        nfree--;
      }
    }
    //degrees of freedom
    dof = nvals - nfree;
  }
}