Ejemplo 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 $mu The location parameter. Default 0.0
 	@param float $variance The scale parameter. Default 1.0
 	@return float The probability
 */
 static function getCdf($x, $mu = 0.0, $variance = 1.0)
 {
     return (1 + \PHPStats\Stats::erf(($x - $mu) / sqrt(2 * $variance))) / 2;
 }
Ejemplo n.º 2
0
 public function test_erf()
 {
     $this->assertEquals(0, round(Stats::erf(0), 7));
     $this->assertEquals(0.5205, round(Stats::erf(0.5), 7));
     $this->assertEquals(0.8427007, round(Stats::erf(1), 7));
     $this->assertEquals(0.9661052999999999, round(Stats::erf(1.5), 7));
     $this->assertEquals(0.9953221, round(Stats::erf(2), 7));
     $this->assertEquals(0.9999993, round(Stats::erf(3.5), 7));
 }