public function gradient(array $coefficients, array $features, float $outcome) : array
{
$error = $this->predicted($coefficients, $features) - $outcome;
$errorSign = $error < 0 ? -1 : 1;
$iterationConstant = $errorSign * $this->power * pow(abs($error), $this->power - 1);
return array_map(function ($feature) use($iterationConstant) {
return $iterationConstant * $feature;
}, $features);
}