Hacker News new | ask | show | jobs
by mrcactu5 4800 days ago
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.