Trend function unit tests (#1089)
* Merge branch 'master' of C:\Projects\PHPOffice\PHPSpreadsheet\develop with conflicts. * More trend function unit tests * Yet more trend function unit tests
This commit is contained in:
parent
6d739f1fe6
commit
a367f35438
|
@ -253,6 +253,22 @@ class StatisticalTest extends TestCase
|
|||
return require 'data/Calculation/Statistical/FORECAST.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerINTERCEPT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testINTERCEPT($expectedResult, array $xargs, array $yargs)
|
||||
{
|
||||
$result = Statistical::INTERCEPT($xargs, $yargs);
|
||||
self::assertEquals($expectedResult, $result, '', 1E-12);
|
||||
}
|
||||
|
||||
public function providerINTERCEPT()
|
||||
{
|
||||
return require 'data/Calculation/Statistical/INTERCEPT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMAXIFS
|
||||
*
|
||||
|
@ -284,4 +300,52 @@ class StatisticalTest extends TestCase
|
|||
{
|
||||
return require 'data/Calculation/Statistical/MINIFS.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerRSQ
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testRSQ($expectedResult, array $xargs, array $yargs)
|
||||
{
|
||||
$result = Statistical::RSQ($xargs, $yargs);
|
||||
self::assertEquals($expectedResult, $result, '', 1E-12);
|
||||
}
|
||||
|
||||
public function providerRSQ()
|
||||
{
|
||||
return require 'data/Calculation/Statistical/RSQ.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSLOPE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSLOPE($expectedResult, array $xargs, array $yargs)
|
||||
{
|
||||
$result = Statistical::SLOPE($xargs, $yargs);
|
||||
self::assertEquals($expectedResult, $result, '', 1E-12);
|
||||
}
|
||||
|
||||
public function providerSLOPE()
|
||||
{
|
||||
return require 'data/Calculation/Statistical/SLOPE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSTEYX
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSTEYX($expectedResult, array $xargs, array $yargs)
|
||||
{
|
||||
$result = Statistical::STEYX($xargs, $yargs);
|
||||
self::assertEquals($expectedResult, $result, '', 1E-12);
|
||||
}
|
||||
|
||||
public function providerSTEYX()
|
||||
{
|
||||
return require 'data/Calculation/Statistical/STEYX.php';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,4 +37,10 @@ return [
|
|||
[-1, -2, -3, -4],
|
||||
[10, 20, 30, 40],
|
||||
],
|
||||
[
|
||||
32.666666666667,
|
||||
7,
|
||||
[3, 7, 15, 20, 22, 27],
|
||||
[1, 2, 3, 4, 5, 6],
|
||||
],
|
||||
];
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
25.0,
|
||||
[5, 10, 15, 20],
|
||||
[12, 9, 6, 3],
|
||||
],
|
||||
[
|
||||
-9.0,
|
||||
[1, 2, 3, 4],
|
||||
[10, 11, 12, 13],
|
||||
],
|
||||
[
|
||||
0.0,
|
||||
[10, 20, 30],
|
||||
[10, 20, 30],
|
||||
],
|
||||
[
|
||||
0.048387096774,
|
||||
[2, 3, 9, 1, 8],
|
||||
[6, 5, 11, 7, 5],
|
||||
],
|
||||
[
|
||||
2.4,
|
||||
[6, 9, 17, 20, 20, 27],
|
||||
[1, 2, 3, 4, 5, 6],
|
||||
],
|
||||
];
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
0.057950191571,
|
||||
[2, 3, 9, 1, 8, 7, 5],
|
||||
[6, 5, 11, 7, 5, 4, 4],
|
||||
],
|
||||
[
|
||||
0.711666290487,
|
||||
[2, 7, 8, 3, 4, 1, 6, 5],
|
||||
[22.9, 33.49, 34.5, 27.61, 19.5, 10.11, 37.90, 31.08],
|
||||
],
|
||||
];
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
|
||||
return [
|
||||
[
|
||||
0.6,
|
||||
[3, 6, 9, 12],
|
||||
[5, 10, 15, 20],
|
||||
],
|
||||
[
|
||||
1.0,
|
||||
[1, 2, 3, 4],
|
||||
[10, 11, 12, 13],
|
||||
],
|
||||
[
|
||||
0.2,
|
||||
[2, 4, 6],
|
||||
[10, 20, 30],
|
||||
],
|
||||
[
|
||||
4.628571428571,
|
||||
[3, 7, 17, 20, 20, 27],
|
||||
[1, 2, 3, 4, 5, 6],
|
||||
],
|
||||
[
|
||||
9.472222222222,
|
||||
[
|
||||
Date::stringToExcel('1900-02-01'),
|
||||
Date::stringToExcel('1900-03-01'),
|
||||
Date::stringToExcel('1900-09-01'),
|
||||
Date::stringToExcel('1900-01-01'),
|
||||
Date::stringToExcel('1900-08-01'),
|
||||
Date::stringToExcel('1900-07-01'),
|
||||
Date::stringToExcel('1900-05-01'),
|
||||
],
|
||||
[
|
||||
6,
|
||||
5,
|
||||
11,
|
||||
7,
|
||||
5,
|
||||
4,
|
||||
4,
|
||||
]
|
||||
],
|
||||
[
|
||||
0.305555555556,
|
||||
[
|
||||
Date::stringToExcel('1900-01-02'),
|
||||
Date::stringToExcel('1900-01-03'),
|
||||
Date::stringToExcel('1900-01-09'),
|
||||
Date::stringToExcel('1900-01-01'),
|
||||
Date::stringToExcel('1900-01-08'),
|
||||
Date::stringToExcel('1900-01-07'),
|
||||
Date::stringToExcel('1900-01-05'),
|
||||
],
|
||||
[
|
||||
6,
|
||||
5,
|
||||
11,
|
||||
7,
|
||||
5,
|
||||
4,
|
||||
4,
|
||||
]
|
||||
],
|
||||
];
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
3.305718950210,
|
||||
[2, 3, 9, 1, 8, 7, 5],
|
||||
[6, 5, 11, 7, 5, 4, 4],
|
||||
],
|
||||
[
|
||||
1.201186346682,
|
||||
[3, 7.9, 8, 9.2, 12, 10.5, 15, 15.5, 17],
|
||||
[1, 2, 3, 4, 4.5, 5, 6, 7, 8],
|
||||
],
|
||||
];
|
Loading…
Reference in New Issue