There are six red balls and three green balls in a box. If we randomly select 3 balls from the box with replacement, and let X be number of green balls selected. So, X ~ Binomial [n=3, p=1/3] Use R to find the following probabilities and answers. A) How likely do we observe exactly one green ball? B) Find P[X<=2]. C) Find the second Decile (the 20th percentile). D) Generating 30 random observations from Bin(n,p) distribution, where n=3 & p=1/3. Find the average and variance of 30 Generated random observations Hint: Check out the posted Lecture notes of Binomial Distribution for dbinom, pbinom, qbinom, and rbinom.
A sample of size 3 is selected from the box with replacement. Hence succesive drawings are independent. Let X denotes the number of green balls selected. .
(A) P[e0xactly one green ball]= P[X=1]= 0.4444444 .
R code: dbinom(1,3,(1/3),log=FALSE)
(B) P[X<=2]= P[X=0]+ P[X=1]+ P[X=2]= 0.962963 .
R code: pbinom(2,3,(1/3),lower.tail=TRUE,log.p=FALSE)
(C) Second decile= 20th percentile= 0 .
R code: qbinom(0.20,3,(1/3),lower.tail=TRUE,log.p=FALSE)
(D) Here we have generated a random sample of 30 observations from Binomial (n=3, p=1/3) distribution and calculated average and variance of the sample observations.
Average= 1.2
Variance= 0.7862069
R code: set.seed(4) # setting the seed value
x= rbinom(30,3,(1/3)) # generating 30 random observations from
Binomial (3,1/3)
mean(x) # for calculating average
var(x) # for calculating variance
Get Answers For Free
Most questions answered within 1 hours.