Additional statistical unit tests (#1818)
This commit is contained in:
parent
5d309e982c
commit
18abae7245
|
|
@ -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';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -16,6 +16,11 @@ return [
|
||||||
-2.5,
|
-2.5,
|
||||||
2,
|
2,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
1,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'#NUM!',
|
'#NUM!',
|
||||||
2.5,
|
2.5,
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,11 @@ return [
|
||||||
2.5,
|
2.5,
|
||||||
-2,
|
-2,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
1,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'#DIV/0!',
|
'#DIV/0!',
|
||||||
123.456,
|
123.456,
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,11 @@ return [
|
||||||
2.5,
|
2.5,
|
||||||
-2,
|
-2,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
1,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'#DIV/0!',
|
'#DIV/0!',
|
||||||
123.456,
|
123.456,
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
@ -45,4 +45,12 @@ return [
|
||||||
10068347520,
|
10068347520,
|
||||||
49, 6,
|
49, 6,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'#NUM!',
|
||||||
|
1, 2,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'#VALUE!',
|
||||||
|
49, 'NaN',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
],
|
||||||
|
];
|
||||||
Loading…
Reference in New Issue