In: Statistics and Probability
Solve following using Program R studio. Please show code and results. Thank you.
1. Assume that ? is a random variable follows binomial probability distribution with parameters 15 and 0.25.
a. Simulate 100 binomial pseudorandom numbers from the given distribution (using set.seed(200)) and assign them to vector called binran.
b. Calculate ?(? < 8) using cumulative probability function.
c. Calculate ?(? = 8) using probability distribution function.
d. Calculate the average of simulated data and compare it with the corresponding theoretical value.
e. Calculate the variance of simulated data and compare it with the corresponding theoretical value.
f. Calculate 95th percentile of ? using quantile function.
(a)
Given that Y is a random variable which follows binomial probability distribution with parameters 15 and 0.25.
15 is the number of trials and 0.25 is the probability of success.
100 pseudorandom numers have to be generated from the given distriibution
The function rbin(n , size ,prob)
where n is the number of values to be generated , size is the number of trials and prob is the probabilty of success
The above command generates 100 random numbers folowing binomial distribution with parameters 15 and 0.25
On execution of the following command we get the follwing output
(b) The vector binran contain 100 pseudo random numbers .
The P(Y<8) has to be calculated using the cumulative distribution function.
The pbinom function is used to calculate the cumulative probability.
pbinom(q,size,prob, lower.tail=TRUE)
On execution of the following command
(c) To calculate the probability P(X= 8 )
we use the function dbinom(x,size,prob)
On execution of the above command ,
(d) The average of the simulated binomail random variable is calculated as
On execution of the above command , the following output is obtained
The average value obtained is 0.17 which is less than the true value of the parameter.
(e) The variance of the simulated data is calculated as
On execution of the above command , we get the following output
(e) To obtain the 95th percentile using the quantile function
On execution of the above command we get the following output