algorithm - Choosing n numbers with fixed sum -


in code want choose n random numbers in [0,1) sum 1.

i choosing numbers independently in [0,1) , normalizing them dividing each 1 total sum:

numbers = [random() in range(n)] numbers = [n/sum(numbers) n in numbers] 

my "problem" is, distribution out quite skew. choosing million numbers not single 1 gets on 1/2. effort i've calculated pdf, , it's not nice.

here weird looking pdf 5 variables:

enter image description here

do have idea nice algorithm choose numbers, result in more uniform or simple distribution?

you looking partition distance 0 1.

choose n - 1 numbers 0 1, sort them , determine distances between each of them.

this partition space 0 1, should yield occasional large result aren't getting.

even so, large values of n, can expect max value decrease well, not method.


Comments

Popular posts from this blog

how to build hyperlink for query string in php -

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

queue - mq_receive: message too long -