Dear All, I am trying to create an artificial binary matrix such that each cell has a probability of 0.048 of having a 1. So far the closest I've come is us by using a random poisson distribution with a mean of 0.048, but I can't figure out how to limit the max value to 1. Otherwise that would work fine it seems. Any suggestions? The main code I've got to create said matrix so far is: a<-replicate(26,rpois(57,0.048)) Thanks in Advance, Mike -- View this message in context: http://old.nabble.com/Create-Artificial-Binary-Matrix-based-on-probability-tp26160620p26160620.html Sent from the R help mailing list archive at Nabble.com.
Dear All, I am trying to create an artificial binary matrix such that each cell has a probability of 0.048 of having a 1. So far the closest I've come is us by using a random poisson distribution with a mean of 0.048, but I can't figure out how to limit the max value to 1. Otherwise that would work fine it seems. Any suggestions? The main code I've got to create said matrix so far is: a<-replicate(26,rpois(57,0.048)) Thanks in Advance, Mike -- View this message in context: http://old.nabble.com/Create-Artificial-Binary-Matrix-based-on-probability-tp26160622p26160622.html Sent from the R help mailing list archive at Nabble.com.
> x <- matrix(sample(0:1, 1200, replace=T, prob=c(0.952, 0.048)), ncol=30) > table(x)x 0 1 1131 69> x <- matrix(sample(0:1, 1200, replace=T, prob=c(0.952, 0.048)), ncol=30) > table(x)x 0 1 1151 49>bikemike42 wrote:> Dear All, > > I am trying to create an artificial binary matrix such that each cell has a > probability of 0.048 of having a 1. So far the closest I've come is us by > using a random poisson distribution with a mean of 0.048, but I can't figure > out how to limit the max value to 1. Otherwise that would work fine it > seems. Any suggestions? > > The main code I've got to create said matrix so far is: > a<-replicate(26,rpois(57,0.048)) > > Thanks in Advance, > Mike