php-ml/tests/Math/Statistic/VarianceTest.php
Marcin Michalski db82afa263 Update to phpunit 8 and bump min php to 7.2 (#367)
* Update to phpunit 8

* Require at least PHP 7.2
2019-04-10 20:42:59 +02:00

35 lines
989 B
PHP

<?php
declare(strict_types=1);
namespace Phpml\Tests\Math\Statistic;
use Phpml\Math\Statistic\Variance;
use PHPUnit\Framework\TestCase;
final class VarianceTest extends TestCase
{
/**
* @dataProvider dataProviderForPopulationVariance
*/
public function testVarianceFromInt(array $numbers, float $variance): void
{
self::assertEqualsWithDelta($variance, Variance::population($numbers), 0.001);
}
public function dataProviderForPopulationVariance(): array
{
return [
[[0, 0, 0, 0, 0, 1], 0.138],
[[-11, 0, 10, 20, 30], 208.16],
[[7, 8, 9, 10, 11, 12, 13], 4.0],
[[300, 570, 170, 730, 300], 41944],
[[-4, 2, 7, 8, 3], 18.16],
[[3, 7, 34, 25, 46, 7754, 3, 6], 6546331.937],
[[4, 6, 1, 1, 1, 1, 2, 2, 1, 3], 2.56],
[[-3732, 5, 27, 9248, -174], 18741676.56],
[[-554, -555, -554, -554, -555, -555, -556], 0.4897],
];
}
}