predict method

double predict(
  1. double x
)

Predicts the y value for a given x.

Implementation

double predict(double x) {
  double result = 0;
  double xPower = 1;
  for (final coef in coefficients) {
    result += coef * xPower;
    xPower *= x;
  }
  return result;
}