[R] "rbinom" not using probability of success right

Charles Annis, P.E. Charles.Annis at StatisticalEngineering.com
Wed May 28 15:06:47 CEST 2008


Do it again.  What did you get this time?  Then do it another time.  Do you
see what is happening?

Charles Annis, P.E.

Charles.Annis at StatisticalEngineering.com
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Philip Twumasi-Ankrah
Sent: Wednesday, May 28, 2008 8:53 AM
To: r-help at r-project.org
Subject: [R] "rbinom" not using probability of success right

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?


A Smile costs Nothing  

     But Rewards Everything

Happiness is not perfected until it is shared
                                                              -Jane Porter



       
	[[alternative HTML version deleted]]

______________________________________________
R-help at 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.



More information about the R-help mailing list