Dividing a number into random unequal parts
Generate 12 random numbers from your favourite random number generator, call them r1..r12
.
Add them all up, call the sum sum
.
Your first random fraction of 4
is (r1/sum)*4
. The rest should be obvious.
Generate any random number greater than 1 and after rescale to required sum.
Example:
- Required sum: 4
- Random Numbers: 1 2 3 4 5 6 7 8 9 10 11 12
- Sum = 78
- Rescaled numbers:
1 rescaled to (1*4) / 78
2 rescaled to (2*4) / 78
...
12 rescaled to (12*4) / 78