News for hackers. Stuff that matters.
Re:Weighted/Biased Random Number Generation with JavaScript ... by mrcactu5 on Monday April 22, 2013 @11:00AM (#5589530)
You can take relative weights (a,b,c) and take the partial sums:

(0,a,a+b,a+b+c)

random() gives values in [0,1], so divide your numbers by a + b + c.

Generating random structures is the tip of a very big iceberg.

There are no comments on this comment yet.