- This question is not a duplicate of Getting N random numbers whose sum is M because:
- Most answers there are about theory, not a specific coding solution in python to answer this question
- The accepted answer here is 5 years older than the one answer in the duplicate that answers this question.
- The duplicate accepted answer does not answer this question
How would I make a list of N (say 100) random numbers, so that their sum is 1?
I can make a list of random numbers with
r = [ran.random() for i in range(1,100)]
How would I modify this so that the list sums to 1 (this is for a probability simulation).