[R] Re : Generate a random bistochastic matrix
Florent Bresson
f_bresson at yahoo.fr
Mon Oct 16 17:03:00 CEST 2006
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
----- Message d'origine ----
De : Dimitris Rizopoulos <dimitris.rizopoulos at med.kuleuven.be>
À : Florent Bresson <f_bresson at yahoo.fr>
Cc : r-help at stat.math.ethz.ch
Envoyé le : Lundi, 16 Octobre 2006, 16h35mn 02s
Objet : Re: [R] Generate a random bistochastic matrix
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
----- Original Message -----
From: "Florent Bresson" <f_bresson at yahoo.fr>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, October 16, 2006 10:22 AM
Subject: [R] Generate a random bistochastic matrix
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 at 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
More information about the R-help
mailing list