lineThroughOriginFunc function

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

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

Implementation

double Function(double) lineThroughOriginFunc(List<double> x, List<double> y) {
  double slope = fitThroughOrigin(x, y);
  return (z) => slope * z;
}