/** Returns the probability distribution function @param float $x The test value @param float $df The degrees of freedeom. Default 1 @return float The probability */ static function getPdf($x, $df = 1) { return pow(1 + pow($x, 2) / $df, -($df + 1) / 2) / (sqrt($df) * \PHPStats\Stats::beta(0.5, $df / 2)); }
/** Returns the probability distribution function @param float $x The test value @param float $alpha The minimum parameter. Default 0.0 @param float $beta The maximum parameter. Default 1.0 @return float The probability */ static function getPdf($x, $alpha = 1, $beta = 1) { if ($x >= 0 && $x <= 1) { return pow($x, $alpha - 1) * pow(1 - $x, $beta - 1) / \PHPStats\Stats::beta($alpha, $beta); } else { return 0.0; } }
public function test_beta() { $this->assertEquals(1, round(Stats::beta(1, 1), 2)); $this->assertEquals(0.5, round(Stats::beta(1, 2), 2)); $this->assertEquals(0.5, round(Stats::beta(2, 1), 2)); $this->assertEquals(0.0015873, round(Stats::beta(5, 5), 7)); $this->assertEquals(0.0002525, round(Stats::beta(5, 8), 7)); }