Re: Filling a 2x2 array with random numbers such that...
- From: Thad Smith <ThadSmith@xxxxxxx>
- Date: Wed, 27 Sep 2006 08:06:06 -0600
Thad Smith wrote:
>>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.
Actually I meant a 2 dimensional matrix. Is it still trivial?
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].
After further consideration, I realized you don't need to use that sequence. You could take any (N-1)x(N-1) array of random numbers, add one more random value and then calculate the rest, based on the constraints.
--
Thad
.
- References:
- Filling a 2x2 array with random numbers such that...
- From: manishwiz
- Re: Filling a 2x2 array with random numbers such that...
- From: websnarf
- Re: Filling a 2x2 array with random numbers such that...
- From: manishwiz
- Re: Filling a 2x2 array with random numbers such that...
- From: Thad Smith
- Filling a 2x2 array with random numbers such that...
- Prev by Date: Re: IT career and getting older
- Next by Date: Re: the lowest number of comparisons in string matching
- Previous by thread: Re: Filling a 2x2 array with random numbers such that...
- Next by thread: Dynamic algorithm for graph connectedness?
- Index(es):
Relevant Pages
|