[R] Binomial simulation

Ranjan Maitra maitra at iastate.edu
Sat Apr 18 18:11:04 CEST 2009


This sounds like a potential homework problem. You don't quite need to
simulate anything if your question is all you have been asked to do.

dbinom(x = 1:10, size = 10, prob = 0.25)

Perhaps you have been asked to simulate 1000 realizations and compare
the relative frequencies with these probabilities: use 

rbinom(n = 1000, size = 10, prob = 0.25)

in that case and compare the relative frequencies.

Btw, there is a small chance of getting a 0. Are you sure the
instructor (or whoever has issued the orders) wants only from 1:10?

HTH!
Ranjan

On Fri, 17 Apr 2009 22:23:11 -0700 (PDT) beetle2
<samandbrendan at aapt.net.au> wrote:

> 
> 
> Not being entirely sure what you mean, I think 
> 
> rbinom(1000, 10, .25) 
> 
> may be what you want. 
> 
> Hi,
> Thanks for your reply.
> It is close to that but I need to know the probabilty of how many judges
> pick a certain brand.
> Just say x= 6 judges pick brand A which has P=0.25.
> 
> Using R it would be:
> > dbinom(6,10,.25)
> [1] 0.016222
> 
> Probability of six judges choosing  brand A. Hence not very likely.
> 
> I have been asked to do this for all values of x = 1 to 10.
> But the question says to simulate 1000 trials for each x value.
> I'm not sure how to construct the simulation.
> regards
> Brendan
> 
> 
> -- 
> View this message in context: http://www.nabble.com/Binomial-simulation-tp23106347p23109522.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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