I am in need of a more generalized solution to this problem.
I have a random number generator that generates numbers from 0 to 1. Using this, I want to find $r$ numbers that add to $n$. How do I do this efficiently, and such that the numbers are uniformly distributed?
For my specific case, I need to be able to generate $6$ numbers that add up to $2\pi$.
Edit: I have thought of possibly using the same method in the other question, but multiplying the final set of numbers by $2\pi$. Would this be uniformly distributed? And if so, how can that be proved (That's just for curiosity's sake though)?
There is an easy way to do this when $r$ is even by using correlated pairs. So, for your problem, here is how:
Generate $X_1 \sim \textrm{Unif}[0,{2 \pi \over 3}]$ and $X_2 = {2 \pi \over 3} - X_1.$ Similarly, generate $X_3 \sim \textrm{Unif}[0,{2 \pi \over 3}]$ and $X_4 = {2 \pi \over 3} - X_3.$ Finally, do the same for the third pair, with $X_5 \sim \textrm{Unif}[0,{2 \pi \over 3}]$ and $X_6 = {2 \pi \over 3} - X_5.$ Every pair sums to ${2 \pi \over 3},$ and the sum of all 6 is $2 \pi$ as required.
Finally, each of the component random variables has a uniform distribution on $[0,{2 \pi \over 3}].$