mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Orange Management
|
|
*
|
|
* PHP Version 7.2
|
|
*
|
|
* @package TBD
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link http://website.orange-management.de
|
|
*/
|
|
|
|
namespace phpOMS\tests\Math\Functions;
|
|
|
|
use phpOMS\Math\Functions\Functions;
|
|
use phpOMS\Math\Functions\Gamma;
|
|
|
|
class GammaTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
public function testFactorial()
|
|
{
|
|
self::assertEquals(Functions::fact(4), Gamma::getGammaInteger(5));
|
|
}
|
|
|
|
public function testApproximations()
|
|
{
|
|
$stirling = [
|
|
2.15697602, 1.20285073, 0.92213701, 0.83974270, 0.85919025, 0.95950218, 1.14910642, 1.45849038, 1.94540320, 2.70976382,
|
|
];
|
|
|
|
$spouge = [
|
|
2.67893853, 1.35411794, 1.00000000, 0.89297951, 0.90274529, 1.00000000, 1.19063935, 1.50457549, 2.00000000, 2.77815848,
|
|
];
|
|
|
|
$gsl = [
|
|
2.67893853, 1.35411794, 1.00000000, 0.89297951, 0.90274529, 1.00000000, 1.19063935, 1.50457549, 2.00000000, 2.77815848,
|
|
];
|
|
|
|
for ($i = 1; $i <= 10; $i++) {
|
|
self::assertEquals($stirling[$i - 1], Gamma::stirlingApproximation($i / 3), '', 0.01);
|
|
self::assertEquals($spouge[$i - 1], Gamma::spougeApproximation($i / 3), '', 0.01);
|
|
self::assertEquals($gsl[$i - 1], Gamma::lanczosApproximationReal($i / 3), '', 0.01);
|
|
}
|
|
}
|
|
}
|