Skip to content

Instantly share code, notes, and snippets.

@dotmanila
Created November 29, 2015 06:00
Show Gist options
  • Save dotmanila/527c88b963c6ed1d780d to your computer and use it in GitHub Desktop.
Save dotmanila/527c88b963c6ed1d780d to your computer and use it in GitHub Desktop.
Pareto Distribution Simulator in PHP
<?php
$pareto_power = log(0.7) / log(1.0-0.7);
function sb_rand_pareto($a, $b) {
global $pareto_power;
return $a + ($b - $a + 1) * pow((double)(rand() % 4294967295) / 4294967295, $pareto_power);
}
for($i=0; $i<=1000; $i++) {
echo sb_rand_pareto(1, 100000) . "\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment