mirror of
https://github.com/furyfire/trueskill.git
synced 2025-05-12 06:07:50 +00:00
41 lines
772 B
PHP
41 lines
772 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DNW\Skills\FactorGraphs;
|
|
|
|
use DNW\Skills\Numerics\GaussianDistribution;
|
|
|
|
class Variable implements \Stringable
|
|
{
|
|
private readonly string $name;
|
|
|
|
private mixed $value;
|
|
|
|
public function __construct(string $name, private GaussianDistribution $prior)
|
|
{
|
|
$this->name = 'Variable[' . $name . ']';
|
|
$this->resetToPrior();
|
|
}
|
|
|
|
public function getValue(): GaussianDistribution
|
|
{
|
|
return $this->value;
|
|
}
|
|
|
|
public function setValue(GaussianDistribution $value): void
|
|
{
|
|
$this->value = $value;
|
|
}
|
|
|
|
public function resetToPrior(): void
|
|
{
|
|
$this->value = $this->prior;
|
|
}
|
|
|
|
public function __toString(): string
|
|
{
|
|
return $this->name;
|
|
}
|
|
}
|