-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional statistical unit tests (#1818)
- Loading branch information
Mark Baker
authored
Jan 31, 2021
1 parent
5d309e9
commit 18abae7
Showing
8 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NegBinomDistTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; | ||
|
||
use PhpOffice\PhpSpreadsheet\Calculation\Functions; | ||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NegBinomDistTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); | ||
} | ||
|
||
/** | ||
* @dataProvider providerNEGBINOMDIST | ||
* | ||
* @param mixed $expectedResult | ||
*/ | ||
public function testNEGBINOMDIST($expectedResult, ...$args): void | ||
{ | ||
$result = Statistical::NEGBINOMDIST(...$args); | ||
self::assertEqualsWithDelta($expectedResult, $result, 1E-12); | ||
} | ||
|
||
public function providerNEGBINOMDIST() | ||
{ | ||
return require 'tests/data/Calculation/Statistical/NEGBINOMDIST.php'; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; | ||
|
||
use PhpOffice\PhpSpreadsheet\Calculation\Functions; | ||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class PoissonTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); | ||
} | ||
|
||
/** | ||
* @dataProvider providerPOISSON | ||
* | ||
* @param mixed $expectedResult | ||
*/ | ||
public function testPOISSON($expectedResult, ...$args): void | ||
{ | ||
$result = Statistical::POISSON(...$args); | ||
self::assertEqualsWithDelta($expectedResult, $result, 1E-12); | ||
} | ||
|
||
public function providerPOISSON() | ||
{ | ||
return require 'tests/data/Calculation/Statistical/POISSON.php'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,11 @@ | |
-2.5, | ||
2, | ||
], | ||
[ | ||
0.0, | ||
0.0, | ||
1, | ||
], | ||
[ | ||
'#NUM!', | ||
2.5, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,11 @@ | |
2.5, | ||
-2, | ||
], | ||
[ | ||
0.0, | ||
0.0, | ||
1, | ||
], | ||
[ | ||
'#DIV/0!', | ||
123.456, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,11 @@ | |
2.5, | ||
-2, | ||
], | ||
[ | ||
0.0, | ||
0.0, | ||
1, | ||
], | ||
[ | ||
'#DIV/0!', | ||
123.456, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
return [ | ||
[ | ||
0.05504866037517786, | ||
10, 5, 0.25, | ||
], | ||
[ | ||
0.047210693359375, | ||
6, 12, 0.5, | ||
], | ||
[ | ||
0.0805901288986206, | ||
12, 12, 0.5, | ||
], | ||
[ | ||
0.057564377784729004, | ||
15, 12, 0.5, | ||
], | ||
[ | ||
'#VALUE!', | ||
15, 12, 'NaN', | ||
], | ||
[ | ||
'#NUM!', | ||
15, 12, -0.25, | ||
], | ||
[ | ||
'#NUM!', | ||
-1, 1, 0.25, | ||
], | ||
[ | ||
'#NUM!', | ||
1, 0.5, 0.25, | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,4 +45,12 @@ | |
10068347520, | ||
49, 6, | ||
], | ||
[ | ||
'#NUM!', | ||
1, 2, | ||
], | ||
[ | ||
'#VALUE!', | ||
49, 'NaN', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
return [ | ||
[ | ||
0.12465201948308113, | ||
2, 5, true, | ||
], | ||
[ | ||
0.08422433748856833, | ||
2, 5, false, | ||
], | ||
[ | ||
0.05191746860849132, | ||
20, 25, false, | ||
], | ||
[ | ||
0.24241419769010333, | ||
35, 40, true, | ||
], | ||
[ | ||
'#NUM!', | ||
35, -40, true, | ||
], | ||
[ | ||
'#VALUE!', | ||
35, 'Nan', true, | ||
], | ||
]; |