Message: 24 Date: Wed, 28 May 2008 05:53:26 -0700 (PDT) From: Philip Twumasi-Ankrah <[EMAIL PROTECTED]> Subject: [R] "rbinom" not using probability of success right To: r-help@r-project.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain
I am trying to simulate a series of ones and zeros (1 or 0) and I am using "rbinom" but realizing that the number of successes expected is not accurate. Any advice out there. This is the example: N<-500 status<-rbinom(N, 1, prob = 0.15) count<-sum(status) 15 percent of 500 should be 75 but what I obtain from the "count" variable is 77 that gives the probability of success to be 0.154. Not very good. Is there another way beyond using "sample" and "rep" together? I understand you correctly you want there to be exactly 75 ones. If this is what you are trying to do then using pseudorandom variables is the incorrect way of going about it. Your suggestion of sample(c(rep (0,545),rep(1,75))) seems to me to be the best way of going about it since conceptually this is what you are doing: taking permutation of a fixed set of numbers. Best, Kyle ______________________________________________ R-help@r-project.org 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.