Re: Filling a 2x2 array with random numbers such that...
- From: Willem <willem@xxxxxxxx>
- Date: Tue, 26 Sep 2006 21:45:11 +0000 (UTC)
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.
Well, if you have an NxN matrix, then you have 2N equations and N*N
variables. That would mean that the grid is fixed after you have randomly
picked N*N-2N numbers. (Including the two desired sums).
One easy way would be to randomly fill an (N-1)x(N-1) grid,
and then randomly select the row and column sums.
(For these last two, you will probably need to calculate a minimum so that
you won't have to fill in negative numbers at the next step.)
Then, you fill in the Nth row so that the column sums add up,
and then fill in the Nth column so that the row sums add up.
Easy peasy.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
.
- Follow-Ups:
- Re: Filling a 2x2 array with random numbers such that...
- From: Pascal Bourguignon
- 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: Filling a 2x2 array with random numbers such that...
- Next by Date: Re: I was thinking of you King Little Richard. You know I am just looking out for you. <g>
- 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):