public function testWeightedChoiceWithNonIntegerWeights()
{
$weights = ['a' => 0.15, 'b' => 0.15, 'c' => 0.1, 'd' => 0.4, 'e' => 0.2];
$pairs = a\pairs($weights);
$appearances = array_fill_keys(array_keys($weights), 0);
for ($i = 0; $i < 50000; ++$i) {
++$appearances[weightedChoice($pairs)];
}
foreach ($appearances as $item => $rate) {
$this->assertEquals(50000 * $weights[$item], $rate, '', 300);
}
}