2022-07-05 15:33:34 +02:00
|
|
|
<?php namespace DNW\Skills\TrueSkill;
|
2010-08-28 22:05:41 -04:00
|
|
|
|
2022-07-05 15:33:34 +02:00
|
|
|
use DNW\Skills\Numerics\GaussianDistribution;
|
2010-08-28 22:05:41 -04:00
|
|
|
|
|
|
|
final class DrawMargin
|
|
|
|
{
|
|
|
|
public static function getDrawMarginFromDrawProbability($drawProbability, $beta)
|
|
|
|
{
|
|
|
|
// Derived from TrueSkill technical report (MSR-TR-2006-80), page 6
|
|
|
|
|
|
|
|
// draw probability = 2 * CDF(margin/(sqrt(n1+n2)*beta)) -1
|
|
|
|
|
|
|
|
// implies
|
|
|
|
//
|
|
|
|
// margin = inversecdf((draw probability + 1)/2) * sqrt(n1+n2) * beta
|
|
|
|
// n1 and n2 are the number of players on each team
|
2016-05-24 14:10:39 +02:00
|
|
|
return GaussianDistribution::inverseCumulativeTo(.5 * ($drawProbability + 1), 0, 1) * sqrt(1 + 1) * $beta;
|
2010-08-28 22:05:41 -04:00
|
|
|
}
|
2016-05-24 14:10:39 +02:00
|
|
|
}
|