[I\'m splitting a population number into different matrices and want to test my code using random numbers for now.]
Quick question guys and thanks for your help in a
One simple way is to pick 8 random numbers between 0 and 100. Add 0 and 100 to the list to give 10 numbers. Sort them. Then output the difference between each successive pair of numbers. For example, here's 8 random numbers between 0 and 100:
96, 38, 95, 5, 13, 57, 13, 20
So add 0 and 100 and sort.
0, 5, 13, 13, 20, 38, 57, 95, 96, 100
Now subtract:
5-0 = 5
13-5 = 8
13-13 = 0
20-13 = 7
38-20 = 18
57-38 = 19
95-57 = 38
96-95 = 1
100-96 = 4
And there you have it, nine numbers that sum to 100: 0, 1, 4, 5, 7, 8, 18, 19, 38. That I got a zero and a one was just a strange bit of luck.