I would like to create in R a Matrix M
M=matrix((sample(c(0,1),size=n*n,replace=TRUE,prob=c(prob0,1-prob0)),n,n)
where, for each (i,j) element, prob0 is drawn from uniform([0,1]) without recurring to a for loop (if it is possible). The general problem of which my issue is a specialization is: is there a way to create in R a matrix, say NxN, in which each element comes from a different distribution without recurring to a for-loop?
Aucun commentaire:
Enregistrer un commentaire