Re: [R] randomize a matrix

2006-10-20 Thread Alex Brown
hi Cameron

It so happens that the particular example P you chose has no  
partners under the symmetry you describe.

Can you explain what this is to be used for?

Could you also give an example of what the operation you desire  
might look like if it was successful, and show exactly what you mean  
by row and column sums?  Does the order of row and column sums have  
to stay the same, ie:

is

0 1
0 0

symmetric with

1 0
0 0

or not?

-Alex Brown

On 19 Oct 2006, at 20:49, Guenther, Cameron wrote:

 Hello everyone,

 If I have an incidence matrix of 0 and 1's

 P=[1 1 1 1 1 1
1 1 1 1 0 0
1 1 1 0 0 0
1 1 1 0 0 0
1 1 0 0 0 0]

 I want to create a new uniform random matrix [a] that is filled  
 with 0's
 and 1's but constrained so that the row and column sums are the  
 same as
 in [P].  Does anyone know how to accomplish this?

 Thanks in advance

 Cameron Guenther, Ph.D.
 Associate Research Scientist
 FWC/FWRI, Marine Fisheries Research
 100 8th Avenue S.E.
 St. Petersburg, FL 33701
 (727)896-8626 Ext. 4305
 [EMAIL PROTECTED]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting- 
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] randomize a matrix

2006-10-20 Thread Giovanni Petris

Cameron,

In your example, I think P is the only matrix with 0-1 entries that
has the given row and column sums. 

In general, I would solve the problem simulating a Markov Chain. Start
from a given incidence matrix A and iterate the following steps:

(1) select two rows, a, b, and two columns, i, j, at random. 

(2) If A[c(a,b), c(i,j)] is of one of the forms

 1 0 or0 1
 0 1   1 0

then set it to the other, i.e. set 
A[c(a,b), c(i,j)] - A[c(b,a), c(i,j)].

After sufficiently many iterations, A will have a uniform
distribution. 

Giovanni


 Date: Thu, 19 Oct 2006 15:49:55 -0400
 From: Guenther, Cameron [EMAIL PROTECTED]
 Sender: [EMAIL PROTECTED]
 Precedence: list
 Thread-topic: [R] randomize a matrix
 Thread-index: Acbzt8BjJUXZEHZgQNaMi9gYYuh3Sg==
 
 Hello everyone,
 
 If I have an incidence matrix of 0 and 1's 
 
 P=[1 1 1 1 1 1
1 1 1 1 0 0 
1 1 1 0 0 0
1 1 1 0 0 0
1 1 0 0 0 0]
 
 I want to create a new uniform random matrix [a] that is filled with 0's
 and 1's but constrained so that the row and column sums are the same as
 in [P].  Does anyone know how to accomplish this?
 
 Thanks in advance  
 
 Cameron Guenther, Ph.D. 
 Associate Research Scientist
 FWC/FWRI, Marine Fisheries Research
 100 8th Avenue S.E.
 St. Petersburg, FL 33701
 (727)896-8626 Ext. 4305
 [EMAIL PROTECTED]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 

 __
[  ]
[ Giovanni Petris [EMAIL PROTECTED] ]
[ Department of Mathematical Sciences  ]
[ University of Arkansas - Fayetteville, AR 72701  ]
[ Ph: (479) 575-6324, 575-8630 (fax)   ]
[ http://definetti.uark.edu/~gpetris/  ]
[__]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.