GaussTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 GaussTest extends TestCase
  7. {
  8. /**
  9. * @dataProvider providerGAUSS
  10. *
  11. * @param mixed $expectedResult
  12. * @param mixed $testValue
  13. */
  14. public function testGAUSS($expectedResult, $testValue): void
  15. {
  16. $result = Statistical::GAUSS($testValue);
  17. self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
  18. }
  19. public function providerGAUSS(): array
  20. {
  21. return require 'tests/data/Calculation/Statistical/GAUSS.php';
  22. }
  23. /**
  24. * @dataProvider providerGaussArray
  25. */
  26. public function testGaussArray(array $expectedResult, string $values): void
  27. {
  28. $calculation = Calculation::getInstance();
  29. $formula = "=GAUSS({$values})";
  30. $result = $calculation->_calculateFormulaValue($formula);
  31. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  32. }
  33. public function providerGaussArray(): array
  34. {
  35. return [
  36. 'matrix' => [
  37. [
  38. [-0.4331927987311418, -0.28814460141660325, 0.07925970943910299],
  39. [0.27337264762313174, 0.39435022633314465, 0.5],
  40. ],
  41. '{-1.5, -0.8, 0.2; 0.75, 1.25, 12.5}',
  42. ],
  43. ];
  44. }
  45. }