Alternative of "stats_rand_gen_normal()".
<?php
/**
* "Box–Muller transform" based random deviate generator.
*
* @ref https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform
*
* @param float|int $av Average/Mean
* @param float|int $sd Standard deviation
* @return float
*/
if (! function_exists('stats_rand_gen_normal')) {
function stats_rand_gen_normal($av, $sd): float
{
$x = mt_rand() / mt_getrandmax();
$y = mt_rand() / mt_getrandmax();
return sqrt(-2 * log($x)) * cos(2 * pi() * $y) * $sd + $av;
}
}
?>