29 ms·
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. Generat
by mrcactu5 14y 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.