ZTestTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
  4. use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
  5. use PHPUnit\Framework\TestCase;
  6. class ZTestTest extends TestCase
  7. {
  8. /**
  9. * @dataProvider providerZTEST
  10. *
  11. * @param mixed $expectedResult
  12. * @param mixed $value
  13. * @param mixed $dataSet
  14. * @param null|mixed $sigma
  15. */
  16. public function testZTEST($expectedResult, $dataSet, $value, $sigma = null): void
  17. {
  18. $result = Statistical::ZTEST($dataSet, $value, $sigma);
  19. self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
  20. }
  21. public function providerZTEST(): array
  22. {
  23. return require 'tests/data/Calculation/Statistical/ZTEST.php';
  24. }
  25. /**
  26. * @dataProvider providerZTestArray
  27. */
  28. public function testZTestArray(array $expectedResult, string $dataSet, string $m0): void
  29. {
  30. $calculation = Calculation::getInstance();
  31. $formula = "=ZTEST({$dataSet}, {$m0})";
  32. $result = $calculation->_calculateFormulaValue($formula);
  33. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  34. }
  35. public function providerZTestArray(): array
  36. {
  37. return [
  38. 'row vector' => [
  39. [
  40. [0.09057419685136381, 0.4516213175273426, 0.8630433891295299],
  41. ],
  42. '{3, 6, 7, 8, 6, 5, 4, 2, 1, 9}',
  43. '{4, 5, 6}',
  44. ],
  45. ];
  46. }
  47. }