FDistTest.php 1.6 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 FDistTest extends TestCase
  7. {
  8. /**
  9. * @dataProvider providerFDIST
  10. *
  11. * @param mixed $expectedResult
  12. */
  13. public function testFDIST($expectedResult, ...$args): void
  14. {
  15. $result = Statistical::FDIST2(...$args);
  16. self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
  17. }
  18. public function providerFDIST(): array
  19. {
  20. return require 'tests/data/Calculation/Statistical/FDIST.php';
  21. }
  22. /**
  23. * @dataProvider providerFDistArray
  24. */
  25. public function testFDistArray(array $expectedResult, string $values, string $u, string $v): void
  26. {
  27. $calculation = Calculation::getInstance();
  28. $formula = "=F.DIST({$values}, {$u}, {$v}, false)";
  29. $result = $calculation->_calculateFormulaValue($formula);
  30. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  31. }
  32. public function providerFDistArray(): array
  33. {
  34. return [
  35. 'row/column vectors' => [
  36. [
  37. [0.005510833927217306, 0.005917159763313607, 0.006191501336451844],
  38. [0.0033829117335328167, 0.00291545189504373, 0.0024239018640028246],
  39. [0.0027880880388152654, 0.002128148956848886, 0.0015205263468794615],
  40. ],
  41. '12',
  42. '{1, 2, 5}',
  43. '{2; 4; 5}',
  44. ],
  45. ];
  46. }
  47. }