WeibullTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 WeibullTest extends TestCase
  7. {
  8. /**
  9. * @dataProvider providerWEIBULL
  10. *
  11. * @param mixed $expectedResult
  12. * @param mixed $value
  13. * @param mixed $alpha
  14. * @param mixed $beta
  15. * @param mixed $cumulative
  16. */
  17. public function testWEIBULL($expectedResult, $value, $alpha, $beta, $cumulative): void
  18. {
  19. $result = Statistical::WEIBULL($value, $alpha, $beta, $cumulative);
  20. self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
  21. }
  22. public function providerWEIBULL(): array
  23. {
  24. return require 'tests/data/Calculation/Statistical/WEIBULL.php';
  25. }
  26. /**
  27. * @dataProvider providerWeibullArray
  28. */
  29. public function testWeibullArray(array $expectedResult, string $values, string $alpha, string $beta): void
  30. {
  31. $calculation = Calculation::getInstance();
  32. $formula = "=WEIBULL({$values}, {$alpha}, {$beta}, false)";
  33. $result = $calculation->_calculateFormulaValue($formula);
  34. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  35. }
  36. public function providerWeibullArray(): array
  37. {
  38. return [
  39. 'row/column vectors' => [
  40. [
  41. [0.18393972058572117, 0.36787944117144233, 0.9196986029286058],
  42. [0.15163266492815836, 0.19470019576785122, 0.07572134644346439],
  43. [0.13406400920712788, 0.1363430062345938, 0.0253391936076857],
  44. ],
  45. '2',
  46. '{1, 2, 5}',
  47. '{2; 4; 5}',
  48. ],
  49. ];
  50. }
  51. }