I'm learning about Probability with Binomial, Poisson and Normal Distributions. I came across some study examples on-line that ask you to do it within R. I was given 10 exercises which were:

enter image description here

I did all 10 within R with this code but I have no idea if the results are correct as I don't know how to check them. My code is:

round(pbinom(5, size = 10, prob = 0.65, lower = F), 4)
round(1 - dbinom(30, size = 100, prob = .2), 4)                 
round(dbinom(15:30, size = 50, prob = .32), 4)
round(dpois(6, lambda = 6) - dpois(8, lambda = 6), 4)
round(ppois(35, lambda = 41, lower = F), 4)
round(sum(dpois(2:5, lambda = 1)), 4)
round(pnorm(12, mean = 7, sd = 2.5, lower = F), 4)
round(pnorm(9.8, mean = 10, sd = 1, lower = F), 4)
round(1 - pnorm(38, mean = 50, sd = 5, lower = F), 4)
round(pnorm(4, mean = 5, sd = 3.6, lower = F), 4)

and the results I got within R are as follows:

enter image description here

If anyone can indicate if my code is actually correct and I'm studying it correctly, it would really help me.

  • $\begingroup$ Personally I use the default lower=TRUE and subtract from 1 if necessary, as this corresponds to the CDF. Your answer to (iii) could either use sum as in (vi) or use the difference of two pbinom. Your answer to (x) should be similar I suspect is currently wrong. I have not checked the others $\endgroup$ – Henry Nov 26 '15 at 18:59
  • $\begingroup$ @Henry: There is a reason the R goods introduced lower=FALSE, in some cases it can preserve higher numerical precision. $\endgroup$ – kjetil b halvorsen May 2 '17 at 21:21

Those don't look exactly right. Try something like this.

iii)round(pbinom(30,50,.32) - pbinom(15,50,.32),4)

pbinom will include the first value you enter, e.g. for i we used pbinom(6,10,.65,lower.tail=FALSE) meaning probability of 6 or more successes.This is the same reason i had to change ii to 29 since we want < 30.

dbinom will give you the probability of exactly that outcome, e.g. if you want to find out the probability of 10 successes with 20 trials and p=.2 you would use dbinom(10,20,.2)

I think this is enough to do all of the problems. There's a pretty good reference here.

| cite | improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.