Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205372

About generating matrix of random numbers following Bernoulli distribution with a probability matrix in R

$
0
0

Assume a probability matrix is A(nxm), then I want to generate a matrix(B) of random numbers of which each follows Bernoulli distribution with corresponding probability in A. That means B[i,j] ~ Bernoulli(A[i,j). Is there anybody knowing how to do that conveniently in R? I even tried rbinom(n*m,1,B), but it didn't work.


Viewing all articles
Browse latest Browse all 205372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>