[R] Re : Generate a random bistochastic matrix

From: Florent Bresson <f_bresson_at_yahoo.fr>
Date: Mon 16 Oct 2006 - 15:03:00 GMT


Thanks, I think it's a shrewd solution, but the problem is that it cannot generate every N*N bistochastic matrix and every cell tends to 1/N as B tends to infinity

Florent Bresson

you can try something like the following:

B <- 10
N <- 5
mats <- r2dtable(B, rep(1, N), rep(1, N)) out <- matrix(0, N, N)
for(i in 1:length(mats))

    out <- out + mats[[i]]
out <- out / B
out
colSums(out)
rowSums(out)

I hope it helps.

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


Please, I would like to generate a random bistochastic matrix, that is a squared matrix of non-negative numbers with each row and each column sum to 1, for example :

.2 .3 .5
.6 .3 .1
.2 .4 .4

I don't know of to code this. Do you have any idea ?

Thanks

Florent Bresson




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.

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



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. Received on Tue Oct 17 01:28:38 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 16 Oct 2006 - 16:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.