/** * 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 testRegularizedGammaPositivePositive2() { $this->assertEquals(0.05265301734, Gamma::regularizedGammaP(5.0, 2.0), '', 1.0E-8); $this->assertEquals(1 - 0.05265301734, Gamma::regularizedGammaQ(5.0, 2.0), '', 1.0E-8); }