FisherInvTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
  4. use PhpOffice\PhpSpreadsheet\Calculation\Functions;
  5. use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
  6. use PHPUnit\Framework\TestCase;
  7. class FisherInvTest extends TestCase
  8. {
  9. protected function setUp(): void
  10. {
  11. Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
  12. }
  13. /**
  14. * @dataProvider providerFISHERINV
  15. *
  16. * @param mixed $expectedResult
  17. * @param mixed $value
  18. */
  19. public function testFISHERINV($expectedResult, $value): void
  20. {
  21. $result = Statistical::FISHERINV($value);
  22. self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
  23. }
  24. public function providerFISHERINV(): array
  25. {
  26. return require 'tests/data/Calculation/Statistical/FISHERINV.php';
  27. }
  28. /**
  29. * @dataProvider providerFisherArray
  30. */
  31. public function testFisherArray(array $expectedResult, string $values): void
  32. {
  33. $calculation = Calculation::getInstance();
  34. $formula = "=FISHERINV({$values})";
  35. $result = $calculation->_calculateFormulaValue($formula);
  36. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  37. }
  38. public function providerFisherArray(): array
  39. {
  40. return [
  41. 'row vector' => [
  42. [[-0.7162978701990245, 0.197375320224904, 0.6351489523872873, 0.9051482536448664]],
  43. '{-0.9, 0.2, 0.75, 1.5}',
  44. ],
  45. ];
  46. }
  47. }