Generate N random numbers whose sum is a constant K - Excel

心不动则不痛 提交于 2019-12-17 16:07:52

问题


How can I generate those numbers in Excel.

I have to generate 8 random numbers whose sum is always 320. I need around 100 sets or so. http://en.wikipedia.org/wiki/User:Skinnerd/Simplex_Point_Picking. Two methods are explained here.

Or any other way so I can do it in Excel.


回答1:


You could use the RAND() function to generate N numbers (8 in your case) in column A.

Then, in column B you could use the following formula B1=A1/SUM(A:A)*320, B2=A2/SUM(A:A)*320 and so on (where 320 is the sum that you are interested into).

So you can just enter =RAND() in A1, then drag it down to A8. Then enter =A1/SUM(A:A)*320 in B1 and drag it to B8. B1:B8 now contains 8 random numbers that sum up to 320.

Sample output:



来源:https://stackoverflow.com/questions/21782329/generate-n-random-numbers-whose-sum-is-a-constant-k-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!