Dividing a number into random unequal parts
algorithm, math, php
Solution
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.
Problem
So I am trying to make a script that will randomly split a value of 4 into 12 different variables. I can't think of a good way to do this properly. I thought about randomizing numbers so that they are close to 0.33 (1/12 of 4) but that would often lead to the last few numbers being underprioritized. Anyone tried anything like this before or have any great ideas for how to make this as random and evenly uneven as possible?