Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 999
sakkthi Avatar asked Feb 14 '14 14:02

sakkthi


People also ask

How do you find random numbers that total to a given amount or value using Excel?

Enter the formula =randbetween(50,150) in cells G11:G16, and =sum(g11:g16) in cell G18. This will generate 6 random numbers between 50 and 150, and their sum. If you target value is in D18, then the following will refresh the random values until the values in D18 and G18 are equal.

How do I randomly generate a random number in Excel?

To get a single random number that doesn't change, enter RANDBETWEEN in the formula bar, press F9 to convert the formula to a static result, and press Enter to enter the value in the cell.

How do you generate a random number from a uniform distribution in Excel?

The Excel RAND function can be used to generate a random real number in a uniform distribution of less than 1 and greater than or equal to 0 unless we specify the range. The RANDBETWEEN function always returns a random integer between two specified values.


1 Answers

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:

enter image description here

like image 76
Razvan Avatar answered Nov 10 '22 07:11

Razvan