Re: Filling a 2x2 array with random numbers such that...
- From: Thad Smith <ThadSmith@xxxxxxx>
- Date: Tue, 26 Sep 2006 22:58:59 -0600
>>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
.
- Follow-Ups:
- Re: Filling a 2x2 array with random numbers such that...
- From: Thad Smith
- Re: Filling a 2x2 array with random numbers such that...
- 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
- Filling a 2x2 array with random numbers such that...
- Prev by Date: Re: LFSR in c
- Next by Date: Re: LFSR in c
- Previous by thread: Re: Filling a 2x2 array with random numbers such that...
- Next by thread: Re: Filling a 2x2 array with random numbers such that...
- Index(es):
Relevant Pages
|