2: return 2.0 * (log($n - 1) + M_EULER) - 2.0 * ($n - 1) / $n; case $n === 2: return 1.0; default: return 0.0; } } /** * Terminate a branch with a dataset. * * @param Dataset $dataset * @param int $depth * @return self */ public static function terminate(Dataset $dataset, int $depth) : self { return new self($depth + self::c($dataset->numSamples()) - 1.0); } /** * @param float $depth * @throws \Rubix\ML\Exceptions\InvalidArgumentException */ public function __construct(float $depth) { $this->depth = $depth; } /** * Return the estimated depth of this node. * * @return float */ public function depth() : float { return $this->depth; } /** * Return the height of the node in the tree. * * @return int */ public function height() : int { return 1; } }