Skip to content

Commit 836eaf8

Browse files
committed
Add unit tests.
1 parent 353fdee commit 836eaf8

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/Statistics/Significance.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Significance
2828
* @param float $Hₐ Alternate hypothesis (M Sample mean)
2929
* @param int $n Sample size
3030
* @param float $H₀ Null hypothesis (μ Population mean)
31-
* @param float $σ SD of population (Standard error of the mean)
31+
* @param float $σ SD of population
3232
*
3333
* @return array{
3434
* z: float,
@@ -61,7 +61,7 @@ public static function zTest(float $Hₐ, int $n, float $H₀, float $σ): array
6161
* @param float $Hₐ Alternate hypothesis (M Sample mean)
6262
* @param int $n Sample size
6363
* @param float $H₀ Null hypothesis (μ Population mean)
64-
* @param float $σ SD of population (Standard error of the mean)
64+
* @param float $σ SD of population
6565
*
6666
* @return array{
6767
* z: float,
@@ -126,7 +126,7 @@ public static function zTestOneSample(float $Hₐ, int $n, float $H₀, float $
126126
* @param float $μ₁ Sample mean of population 1
127127
* @param float $μ₂ Sample mean of population 2
128128
* @param int $n₁ Sample size of population 1
129-
* @param int $n₂ Sample size of population 1
129+
* @param int $n₂ Sample size of population 2
130130
* @param float $σ₁ Standard deviation of sample mean 1
131131
* @param float $σ₂ Standard deviation of sample mean 2
132132
* @param float $Δ (Optional) hypothesized difference between the population means (0 if testing for equal means)
@@ -441,7 +441,7 @@ public static function tTestTwoSample(array $x₁, array $x₂): array
441441
* @param float $μ₁ Sample mean of population 1
442442
* @param float $μ₂ Sample mean of population 2
443443
* @param int $n₁ Sample size of population 1
444-
* @param int $n₂ Sample size of population 1
444+
* @param int $n₂ Sample size of population 2
445445
* @param float $σ₁ Standard deviation of sample mean 1
446446
* @param float $σ₂ Standard deviation of sample mean 2
447447
*

tests/Statistics/SignificanceTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,27 @@ public function dataProviderFortTestTwoSampleDataSet(): array
547547
20.67941, 22.135, 68, 300, 2.820266, 0.9252723,
548548
['t' => -4.205026, 'df' => 70.29978, 'p1' => 0.000076, 'p2' => 7.568864e-05],
549549
],
550+
// One sample with zero variance (first sample constant)
551+
[
552+
[10, 10, 10, 10],
553+
[8, 10, 12],
554+
10, 10, 4, 3, 0, 2,
555+
['t' => 0, 'df' => 2, 'p1' => 0.5, 'p2' => 1],
556+
],
557+
// One sample with zero variance (second sample constant)
558+
[
559+
[8, 10, 12, 14],
560+
[10, 10, 10],
561+
11, 10, 4, 3, 2.5819888974716, 0,
562+
['t' => 0.7745967, 'df' => 3, 'p1' => 0.24751265, 'p2' => 0.4950253],
563+
],
564+
// One sample with zero variance (first sample constant, equal means)
565+
[
566+
[5, 5, 5, 5, 5],
567+
[1, 3, 5, 7, 9],
568+
5, 5, 5, 5, 0, 3.162278,
569+
['t' => 0, 'df' => 4, 'p1' => 0.5, 'p2' => 1],
570+
],
550571
];
551572
}
552573

0 commit comments

Comments
 (0)