mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-15 17:57:11 +00:00
01bb82a2a7
* One-v-Rest Classification technique applied to linear classifiers * Fix for Apriori * Fixes for One-v-Rest * One-v-Rest test cases
29 lines
712 B
PHP
29 lines
712 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace test\Phpml\Math\StandardDeviation;
|
|
|
|
use Phpml\Math\Statistic\Gaussian;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class GaussianTest extends TestCase
|
|
{
|
|
public function testPdf()
|
|
{
|
|
$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);
|
|
}
|
|
}
|
|
}
|