Lets assume we have a method that generates a uniformly random distribution of numbers between [0,N]
. An obvious way is to successively generate M
random numbers in the range from [0,N]
where we update N after each generation, since the sum of all generated numbers has to equal N
. You would have to mathematically prove that this will result in a uniformly randomly distributed collection of pairs [x1,x2,....,xM]
. I would say that this is not trivial. (For instance your example where the first number is randomly chosen to be 5, the following two numbers have to be zero as the sum can not exceed N=5
and therefore the randomnness is biased)
Another 'brute force' method that you might consider is generating a collection of all possible permutations [x1,x2,....,xM]
where the sum x1+x2+...+xM = N
. If the collection contains Y
possible permutations you can then use our previously defined random generator to get a random number in the range [1,Y]
and select that element from your collection
Note that this is just of the top of my head and if you want to ensure truely random uniform distributions you have to check these proposals mathematically.
Edit: I also just realized that probably, they way you described the problem, the order in which the number is split is irrelevant (i.e. [0,2,3]
is the same as [2,3,0]
is the same as [0,3,2]
). This reduces the number of total unique permutation in the ensemble of Y
groupings