/**
  * @param array $gradient
  * @param array $coefficients
  * @return bool
  */
 public function converged(array $gradient, array $coefficients) : bool
 {
     $steppedGradient = [];
     foreach ($gradient as $i => $slope) {
         $steppedGradient[] = $this->schedule->step($i) * $slope;
     }
     return $this->criteria->converged($steppedGradient, $coefficients);
 }
 /**
  * @param Observations $observations
  * @return array
  */
 public final function regress(Observations $observations) : array
 {
     $coefficients = array_fill(0, $observations->getFeatureCount(), 0.0);
     do {
         $gradient = $this->calculateGradient($observations, $coefficients);
         $this->schedule->update($gradient);
         $coefficients = $this->updateCoefficients($coefficients, $gradient);
     } while (!$this->stoppingCriteria->converged($gradient, $coefficients));
     return $coefficients;
 }