public static tTestTwoSample ( number $μ₁, number $μ₂, number $n₁, number $n₂, number $σ₁, number $σ₂, number $Δ ) : array | ||
$μ₁ | number | Sample mean of population 1 |
$μ₂ | number | Sample mean of population 2 |
$n₁ | number | Sample size of population 1 |
$n₂ | number | Sample size of population 1 |
$σ₁ | number | Standard deviation of sample mean 1 |
$σ₂ | number | Standard deviation of sample mean 2 |
$Δ | number | (Optional) hypothesized difference between the population means (0 if testing for equal means) |
리턴 | array | [ t => t score p1 => one-tailed p value p2 => two-tailed p value ] |
public static function tTestTwoSample($μ₁, $μ₂, $n₁, $n₂, $σ₁, $σ₂, $Δ = 0) : array
{
// Calculate t score (test statistic)
$t = ($μ₁ - $μ₂ - $Δ) / sqrt($σ₁ ** 2 / $n₁ + $σ₂ ** 2 / $n₂);
// Degrees of freedom
$ν = $n₁ - 1 + ($n₂ - 1);
// One- and two-tailed P values
$p1 = StudentT::above(abs($t), $ν);
$p2 = StudentT::outside(-abs($t), abs($t), $ν);
return ['t' => $t, 'p1' => $p1, 'p2' => $p2];
}