/** * Compute the p-value of null-hypothesis holds. * * Warning: please read * http://en.wikipedia.org/wiki/P-value#Frequent_misunderstandings * or consult statistician how to interpret results. * * @param int $degreesOfFreedom If you have 1-D histogram * analysis, $degreesOfFreedom should be number of bins-1. * For other scenarios, please consult statistician. * @param double $chisqr result of chi-square test * * @returns double p-value. */ static function pvalue($degreesOfFreedom, $chisqr) { Preconditions::check(is_int($degreesOfFreedom)); Preconditions::check($degreesOfFreedom > 0); Preconditions::checkIsNumber($chisqr); Preconditions::check($chisqr >= 0); return Gamma::regularizedGammaQ($degreesOfFreedom / 2.0, $chisqr / 2.0); }
public function testLogGammaPositive() { $this->assertEquals(0.6931471806, Gamma::logGamma(3.0), '', 1.0E-9); $this->assertEquals(71.2570389672, Gamma::logGamma(30.0), '', 1.0E-9); $this->assertEquals(-0.08537409, Gamma::logGamma(1.2), '', 1.0E-9); }