coefficients = Vector::quick($coefficients); $this->intercept = $intercept; $this->noise = $noise; } /** * Return the dimensionality of the data this generates. * * @internal * * @return int<0,max> */ public function dimensions() : int { return $this->coefficients->n(); } /** * Generate n data points. * * @param int<0,max> $n * @return Labeled */ public function generate(int $n) : Labeled { $d = $this->dimensions(); $y = Vector::uniform($n); $noise = Matrix::gaussian($n, $d) ->multiply($this->noise); $samples = $y->add($this->intercept) ->asColumnMatrix() ->repeat(0, $d - 1) ->multiply($this->coefficients) ->add($noise) ->asArray(); $labels = $y->asArray(); return Labeled::quick($samples, $labels); } }