Re: Filling a 2x2 array with random numbers such that...



>>manishwiz@xxxxxxxxx wrote:
>>
>>>I need to RANDOMLY fill a 2x2 matrix such that the sum of each of >>>rows
>>>is same and the sum of each of the columns is same and these two sums
>>>need not be same. the two sums shall be given.

manishwiz@xxxxxxxxx wrote:
omg! Was too sleepy and typed 2x2. I can't believe it!
Actually I meant a 2 dimensional matrix. Is it still trivial?
I apologize for the mistake.

If the sum of rows are the same, they will be the same as the sum of the columns if you have a square matrix. Each row or column is T/N, where T is the sum of all elements.

I think it is fairly trivial without any other requirements. Choose N random values for the first row. That determines the sum. Now choose N-2 random variables for the first column. The fix row entry is fixed, the last is constrained to give the same sum. Now populate the second row with N-2 random values, assigning the last with the required value. Continue seeding alternating rows and columns. The last random value is M[n-1][n-1].

--
Thad
.



Relevant Pages

  • Re: Subrange
    ... A without first row". ... Microsoft Excel MVP ... sum of negative increments: ... sum of positive and negative increments. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: aggregation
    ... and "country" data from the first row ... The only way I've found so far is to use the "group by" and "sum" method, ... > In your query design, simply GroupBy the Name and Sum on the Owes column ...
    (microsoft.public.access.forms)
  • Re: Filling a matrix with values
    ... For every cell C, make a sum of the cell "just above C" ... the first row and the ... Good luck using APL. ...
    (comp.lang.apl)
  • Re: how to count total record and amount
    ... Put this formula in the first row of your data and suse ... This should deal with variable record numbers. ... > currently i put this function(count and sum) at row 200 as user told me ... >> why use a macro?. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: sum a column within a name definition
    ... Microsoft Excel MVP ... Will sum column F within the range D, ... to start on the first row of the range D, 3 says we want to start 3 columns ... to sum up column C's values without have to explicitly type C2:C13. ...
    (microsoft.public.excel.misc)