lineFunc function

double Function(double) lineFunc(
  1. List<double> x,
  2. List<double> y
)

Least-Squares fitting the points (x,y) to a line y : x -> a+b*x, returning a function y' for the best fitting line.

Implementation

double Function(double) lineFunc(List<double> x, List<double> y) {
  var parameters = fit(x, y);
  double intercept = parameters.item1, slope = parameters.item2;
  return (z) => intercept + slope * z;
}