I'm fairly new to RStudio and I wondered if a function is available that performs a random Bernoulli trial from a given probability matrix. So I've got a 15.000 by 5 matrix with probabilities and I want to turn all of these probabilities into a single binary outcome so that my output will be a 15.000 by 5 matrix as well. For instance, if the first element of my probability matrix is 0.8, the first element of my output matrix will be 1 with a probability of 0.8. I know RStudio contains a function rbinom that produces this outcome for 1 element, but I only get a scalar outcome when I insert my probability matrix in this function.
I know MATLAB has this function called binornd that produces this outcome for a given matrix.
I hope you can help me with this issue.