public static zTest ( number $Hₐ, integer $n, number $H₀, number $σ ) : array | ||
$Hₐ | number | Alternate hypothesis (M Sample mean) |
$n | integer | Sample size |
$H₀ | number | Null hypothesis (μ Population mean) |
$σ | number | SD of population (Standard error of the mean) |
return | array | [ z => z score p1 => one-tailed p value (left or right tail depends on how Hₐ differs from H₀) p2 => two-tailed p value ] |
public static function zTest($Hₐ, $n, $H₀, $σ) : array
{
// Calculate z score (test statistic)
$sem = self::sem($σ, $n);
$z = self::zScore($Hₐ, $H₀, $sem, self::Z_RAW_VALUE);
// One- and two-tailed P values
if ($Hₐ < $H₀) {
$p1 = StandardNormal::CDF($z);
} else {
$p1 = StandardNormal::above($z);
}
$p2 = StandardNormal::outside(-abs($z), abs($z));
return ['z' => $z, 'p1' => $p1, 'p2' => $p2];
}