mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-10-01 01:19:11 +00:00
70b4ecd4d3
They aren't quite interchangeable. Both are used in the test suite, with no indication of why one or the other. I think we'd be best off being consistent. Based on the names, I think `_calculateFormulaValue` was intended as a private, or at least internal, method, so favor `calculateFormula`. I do not intend to rename or re-categorize `_calculateFormulaValue`, just remove its usage when it isn't clearly warranted.
61 lines
2.0 KiB
PHP
61 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
|
|
|
class ChiInvRightTailTest extends AllSetupTeardown
|
|
{
|
|
#[\PHPUnit\Framework\Attributes\DataProvider('providerCHIINV')]
|
|
public function testCHIINV(mixed $expectedResult, mixed ...$args): void
|
|
{
|
|
$this->runTestCases('CHISQ.INV.RT', $expectedResult, ...$args);
|
|
}
|
|
|
|
public static function providerCHIINV(): array
|
|
{
|
|
return require 'tests/data/Calculation/Statistical/CHIINVRightTail.php';
|
|
}
|
|
|
|
public function invVersusDistTest(): void
|
|
{
|
|
$expectedResult = 8.383430828608;
|
|
$probability = 0.3;
|
|
$degrees = 7;
|
|
$calculation = Calculation::getInstance();
|
|
$formula = "=CHISQ.INV.RT($probability, $degrees)";
|
|
/** @var float|int|string */
|
|
$result = $calculation->calculateFormula($formula);
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-8);
|
|
$formula = "=CHISQ.DIST.RT($result, $degrees)";
|
|
$result = $calculation->calculateFormula($formula);
|
|
self::assertEqualsWithDelta($probability, $result, 1.0e-8);
|
|
}
|
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider('providerChiInvRightTailArray')]
|
|
public function testChiInvRightTailArray(array $expectedResult, string $probabilities, string $degrees): void
|
|
{
|
|
$calculation = Calculation::getInstance();
|
|
|
|
$formula = "=CHISQ.INV.RT({$probabilities}, {$degrees})";
|
|
$result = $calculation->calculateFormula($formula);
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
|
|
}
|
|
|
|
public static function providerChiInvRightTailArray(): array
|
|
{
|
|
return [
|
|
'row/column vectors' => [
|
|
[
|
|
[7.8061229155968075, 6.345811195521517, 100.0],
|
|
[13.266097125199911, 11.34032237742413, 24.388802783239434],
|
|
],
|
|
'{0.35, 0.5, 0.018}',
|
|
'{7; 12}',
|
|
],
|
|
];
|
|
}
|
|
}
|