center = Vector::quick([$x, $y]); $this->scale = $scale; $this->noise = $noise; } /** * Return the dimensionality of the data this generates. * * @internal * * @return int<0,max> */ public function dimensions() : int { return 2; } /** * Generate n data points. * * @param int<0,max> $n * @return Labeled */ public function generate(int $n) : Labeled { $r = Vector::rand($n)->multiply(TWO_PI); $x = $r->cos()->asArray(); $y = $r->sin()->asArray(); $coordinates = array_transpose([$x, $y]); $noise = Matrix::gaussian($n, 2) ->multiply($this->noise); $samples = Matrix::quick($coordinates) ->multiply($this->scale) ->add($this->center) ->add($noise) ->asArray(); $labels = $r->rad2deg()->asArray(); return Labeled::quick($samples, $labels); } }