Hi Guy's I was wondering if someone could point me in the right direction. dbinom(10,1,0.25) I am using dbinom(10,1,0.25) to calculate the probabilty of 10 judges choosing a certain brand x times. I was wondering how I would go about simulating 1000 trials of each x value ? regards Brendan -- View this message in context: http://www.nabble.com/Binomial-simulation-tp23106347p23106347.html Sent from the R help mailing list archive at Nabble.com.
beetle2 <samandbrendan at aapt.net.au> [Fri, Apr 17, 2009 at 11:28:56PM CEST]:> > Hi Guy's > I was wondering if someone could point me in the right direction. > > dbinom(10,1,0.25) > > I am using dbinom(10,1,0.25) to calculate the probabilty of 10 judges > choosing a certain brand x times.dbinom returns the discrete density of the binomial distribution, which is in your case .75 at 0, .25 at 1 and 0 elsewhere (such as at 10). Is dbinom(0:10, 10, .25) what you are driving at?> > I was wondering how I would go about simulating 1000 trials of each x value > ?Not being entirely sure what you mean, I think rbinom(1000, 10, .25) may be what you want. -- Johannes H?sing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:johannes at huesing.name from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, "Life on the Mississippi")
Sorry guys one quick question I've graphed the histogram with hist(rbinom(n = 1000, size = 10, prob = 0.25)) How to I sum the individual values 0 to 12? regards Brendan beetle2 wrote:> > Hi Guy's > I was wondering if someone could point me in the right direction. > > dbinom(10,1,0.25) > > I am using dbinom(10,1,0.25) to calculate the probabilty of 10 judges > choosing a certain brand x times. > > I was wondering how I would go about simulating 1000 trials of each x > value ? > > regards > Brendan > >-- View this message in context: http://www.nabble.com/Binomial-simulation-tp23106347p23117871.html Sent from the R help mailing list archive at Nabble.com.
I'm thinking I will just use: results <- rbinom(1000, 10, .25) d = sum(results == 0 ) df = (d/1000) df And do each individually beetle2 wrote:> > Hi Guy's > I was wondering if someone could point me in the right direction. > > dbinom(10,1,0.25) > > I am using dbinom(10,1,0.25) to calculate the probabilty of 10 judges > choosing a certain brand x times. > > I was wondering how I would go about simulating 1000 trials of each x > value ? > > regards > Brendan > >-- View this message in context: http://www.nabble.com/Binomial-simulation-tp23106347p23118747.html Sent from the R help mailing list archive at Nabble.com.
I've done some study. And made a couple of loops to compare the dbinom() and rbinom() Here are the results: The instructor only asked for 1000 trials so its not that accurate. but its close to it.> for(x in c(1:10))+ {print(dbinom(x,10,.25)) } [1] 0.1877117 [1] 0.2815676 [1] 0.2502823 [1] 0.145998 [1] 0.0583992 [1] 0.016222 [1] 0.003089905 [1] 0.0003862381 [1] 2.861023e-05 [1] 9.536743e-07> > results <- rbinom(1000, 10, .25) > for (x in c(1:10) )+ {d=sum(results == x) + df = (d/1000) + print(df) + } [1] 0.173 [1] 0.279 [1] 0.274 [1] 0.15 [1] 0.059 [1] 0.013 [1] 0.004 [1] 0 [1] 0 [1] 0>Thanks for pointing me to the rbinom() function regards Brendan beetle2 wrote:> > Hi Guy's > I was wondering if someone could point me in the right direction. > > dbinom(10,1,0.25) > > I am using dbinom(10,1,0.25) to calculate the probabilty of 10 judges > choosing a certain brand x times. > > I was wondering how I would go about simulating 1000 trials of each x > value ? > > regards > Brendan > >-- View this message in context: http://www.nabble.com/Binomial-simulation-tp23106347p23118881.html Sent from the R help mailing list archive at Nabble.com.
Hi All, Thank you for all your help. In future I will state if it's homework related. regards Brendan beetle2 wrote:> > Hi Guy's > I was wondering if someone could point me in the right direction. > > dbinom(10,1,0.25) > > I am using dbinom(10,1,0.25) to calculate the probabilty of 10 judges > choosing a certain brand x times. > > I was wondering how I would go about simulating 1000 trials of each x > value ? > > regards > Brendan > >-- View this message in context: http://www.nabble.com/Binomial-simulation-tp23106347p23128391.html Sent from the R help mailing list archive at Nabble.com.