php-ml/tests/Phpml/Math/Statistic/GaussianTest.php
Tomáš Votruba a348111e97 Add PHPStan and level to max (#168)
* tests: update to PHPUnit 6.0 with rector

* fix namespaces on tests

* composer + tests: use standard test namespace naming

* update travis

* resolve conflict

* phpstan lvl 2

* phpstan lvl 3

* phpstan lvl 4

* phpstan lvl 5

* phpstan lvl 6

* phpstan lvl 7

* level max

* resolve conflict

* [cs] clean empty docs

* composer: bump to PHPUnit 6.4

* cleanup

* composer + travis: add phpstan

* phpstan lvl 1

* composer: update dev deps

* phpstan fixes

* update Contributing with new tools

* docs: link fixes, PHP version update

* composer: drop php-cs-fixer, cs already handled by ecs

* ecs: add old set rules

* [cs] apply rest of rules
2018-01-06 13:09:33 +01:00

29 lines
708 B
PHP

<?php
declare(strict_types=1);
namespace Phpml\Tests\Math\Statistic;
use Phpml\Math\Statistic\Gaussian;
use PHPUnit\Framework\TestCase;
class GaussianTest extends TestCase
{
public function testPdf(): void
{
$std = 1.0;
$mean = 0.0;
$g = new Gaussian($mean, $std);
// Allowable error
$delta = 0.001;
$x = [0, 0.1, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0];
$pdf = [0.3989, 0.3969, 0.3520, 0.2419, 0.1295, 0.0539, 0.0175, 0.0044];
foreach ($x as $i => $v) {
$this->assertEquals($pdf[$i], $g->pdf($v), '', $delta);
$this->assertEquals($pdf[$i], Gaussian::distributionPdf($mean, $std, $v), '', $delta);
}
}
}