Created
November 29, 2015 06:00
-
-
Save dotmanila/527c88b963c6ed1d780d to your computer and use it in GitHub Desktop.
Pareto Distribution Simulator in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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