Exemplo n.º 1
0
 /**
 	Returns the cumulative distribution function, the probability of getting the test value or something below it
 	
 	@param float $x The test value
 	@param float $df The degrees of freedeom.  Default 1
 	@return float The probability
 */
 static function getCdf($x, $df = 1)
 {
     $return = 1 - 0.5 * \PHPStats\Stats::regularizedIncompleteBeta($df / 2, 0.5, $df / (pow($x, 2) + $df));
     //Valid only for $x > 0
     if ($x < 0) {
         return 1 - $return;
     } elseif ($x == 0) {
         return 0.5;
     } else {
         return $return;
     }
 }
Exemplo n.º 2
0
 /**
 	Returns the cumulative distribution function, the probability of getting the test value or something below it
 	
 	@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 getCdf($x, $alpha = 1, $beta = 1)
 {
     return \PHPStats\Stats::regularizedIncompleteBeta($alpha, $beta, $x);
 }
Exemplo n.º 3
0
 public function test_regularizedIncompleteBeta()
 {
     $this->assertEquals(0.25, round(Stats::regularizedIncompleteBeta(1, 1, 0.25), 5));
     $this->assertEquals(0.4375, round(Stats::regularizedIncompleteBeta(1, 2, 0.25), 5));
     $this->assertEquals(0.0625, round(Stats::regularizedIncompleteBeta(2, 1, 0.25), 5));
     $this->assertEquals(0.73343, round(Stats::regularizedIncompleteBeta(5, 5, 0.6), 5));
     $this->assertEquals(0.94269, round(Stats::regularizedIncompleteBeta(5, 8, 0.6), 5));
 }