MathPHP\Statistics\Significance::tTestTwoSample PHP Метод

tTestTwoSample() публичный статический Метод

https://en.wikipedia.org/wiki/Student%27s_t-test μ₁ - μ₂ - Δ z = -------------- _________ σ₁² σ₂² --- + --- √ n₁ n₂ where μ₁ is sample mean 1 μ₂ is sample mean 2 Δ is the hypothesized difference between the population means (0 if testing for equal means) σ₁ is standard deviation of sample mean 1 σ₂ is standard deviation of sample mean 2 n₁ is sample size of mean 1 n₂ is sample size of mean 2 For Student's t distribution CDF, degrees of freedom: ν = (n₁ - 1) + (n₂ - 1) p1 = CDF above p2 = CDF outside
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];
    }