In: Statistics and Probability
Instructions: You are not required to use R markdown for the lab assignment. Please include ALL R commands you used to reach your answers in a word or pdf document. Also, report everything you are asked to do so.
Problem 1 : Consider a binomial random variable X ∼ Bin(100, 0.01). 1. Report P(X = 7), P(X = 8), P(X = 9), try to use one ONE R command to return all these three values. 2. Find the probability P(0 ≤ X < 5), be careful when treating “end points” 0 and 5. 3. We have mentioned on the class Possion distribution could be a good approximation of Binomial distribution under certain conditions. Here, n = 100, p = 0.01, np = 1 looks satisfy the condition that the pmf of X can be approximated by a suitable Possion random variable Y . What is λ of Y ? Compute P(X = i), P(Y = i), i = 0, 1, 2, 3, 4, 5 to show the goodness of the approximation.
Problem 2 : Answer the following questions: 1. First run alphas <- seq(0.1, 1, by = 0.1) and nalphas <- - rev(alphas). Based on what you have seen, decribe how functions seq and rev work. Then run qnorm(c(nalphas, alphas)) and report the result you get. What are they? What pattern did you notice and why? 2. Use the function rnorm to genearate 10000 random numbers from N(50, 4), store those random numbers into a vector called firstrn. It is expected that the sample mean of firstrn should be close to the population mean 50. Use the function mean to verify this. 3. Suppose X ∼ Possion(2). Report the probability that P(1 < X ≤ 5). Show the code you used to reach this answer.
Problem 3 : In lab lecture notes and demo code, I simulated random samples from Exp(1) to verify classical central limit theorem numerically. I also stressed that no matter what type of random samples you use, the standardized partial sum Sn always converge to N(0, 1). In this problem, simulate random samples from the following distributions: 1. Bernoulli(0.5) with µ = 0.5 and σ2 = 0.25. (Hint: You can use rbinom to generate Bernoulli random numbers.) 1 2. Uniform(0, 1) with µ = 0.5 and σ2 = 1/12. 3. Possion(1) with µ = 1 and σ2 = 1. For each case, set simulation times N to be 1000 and for each simulation, generate n = 2000 random numbers. Report 3 pieces of code, 3 Q-Q plots and your conclusion. To get all the answers, you only need slightly adjust my demo code
Given:-
Binomial Random variable X ∼ Bin(100, 0.01)
(1)
#binomial distribution probability mass function with size
= 100, prob = 0.01
#probability at X = 7,8,9
dbinom(7:9, 100, 0.01)
which gives output as P(X=7) = 6.286346e-05; P(X=8) = 7.381694e-06; P(X=9) = 7.621951e-07
(2)
P(0<=X<5) will be equivalent to cumulative probability till
X=4
#cumulative probability
#P(0<=X<5)
pbinom(4, 100, 0.01)
sum(dbinom(0:4, 100, 0.01))
Both gives same output i.e. P(0<=X<5) =
0.9965677
Either directly use cumulative probability function or sum each
probability from 0 to 4
(3)
When binomial distriution is approximated into Poisson
distribution, its
= np where n = size= 100, p = prob = 0.01
So,
= 100*0.01 = 1
Compute poisson distriution prob and binom prob at i = 0,1,2,3,4,5 for goodness of approximation result
#binomial probability at X = 0:5
dbinom(0:5, 100, 0.01)
#poisson probability at Y = 0:5 with
= 1
dpois(0:5, 1)
which gives us result as
Binom prob at 0:5 = {0.366032341, 0.369729638, 0.184864819,
0.060999166, 0.014941715, 0.002897787}
Poisson prob at 0:5 = {0.367879441, 0.367879441, 0.183939721,
0.061313240, 0.015328310, 0.003065662}
We can see the corresponding probabilities are approximately same.
Hence we can say that poisson distribution in this case is a good
approximation of binomial distribution with n = 100, p = 0.01
If you have any doubt, feel free to ask in comment box. Please do upvote.