code_junkie

Generating random results by weight in PHP?

Nov 13th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.16 KB | None | 0 0
  1. function weightedrand($min, $max, $gamma) {
  2. $offset= $max-$min+1;
  3. return floor($min+pow(lcg_value(), $gamma)*$offset);
  4. }
  5. echo(weightedrand(1, 10, 1.5));
Add Comment
Please, Sign In to add comment