Q1 Consider X~Bin(100,0.01). Report P(X=7), P(X=8), P (X=9), try to use ONLY ONE
ID: 3351594 • Letter: Q
Question
Q1
Consider X~Bin(100,0.01).
Report P(X=7), P(X=8), P (X=9), try to use ONLY ONE line of command to return all these three values.
Use two different ways to find the probability P(0X<5)P(0X<5), be careful when treating “end points” 0 and 5.
For the parameters, n=100, p=0.01, np=1. It seems to satisfy the condition that the pmf of X can be approximated by a Poisson random variable Y with = np. Compute P (X = i), P (Y = i), i = 0, 1, 2, 3, 4 respectively and see whether the Poisson approximation performs well (You may use the method in part 1 to store the result in one vector for each of X and Y ).
Q2
Work through code on finding QQ-plot of a sequence of numbers shown on kaggle (no need to submit).
Generate 10000 random numbers from N(50,4), store them as a vector. It is expected that the sample mean of this vector should be close to the population mean 50. Verify this.
Suppose X~NB(3,0.8). More specificly, let X be the total numbers needed to achieve 3rd success in a sequence of independent repeated Bernoulli trials with success probability 0.8. Report the probability that P (5 < X 10).
Q3
Simulate random samples from the following distributions:
Bernoulli(0.5) (so that = 0.5 and ^2 = 0.25). (Hint: You can use rbinom to generate Bernoulli random numbers.)
Uniform(0, 1) (so that = 0.5 and ^2 = 1/12).
Possion(1) (so that = 1 and ^2 = 1).
For each case, set the number of simulations 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. You only need to slightly modify the demo code to get the right answer.
Explanation / Answer
Q1.
> ## P(X=7)
>
> P_7=dbinom(7, size=100, prob=0.01)
> P_7
[1] 6.286346e-05
> ## P(X=8)
> P_8=dbinom(8, size=100, prob=0.01)
> P_8
[1] 7.381694e-06
> ## P (X=9)
> P_9=dbinom(9, size=100, prob=0.01)
> P_9
[1] 7.621951e-07
> ## P(0X<5)
>
> P_05=sum(dbinom(4, size=100, prob=0.01)+dbinom(3, size=100, prob=0.01)
+ +dbinom(2, size=100, prob=0.01)+dbinom(1, size=100, prob=0.01)
+ +dbinom(0, size=100, prob=0.01))-dbinom(0, size=100, prob=0.01)
> P_05
[1] 0.6305353
# OR
> ## Using cummulative
> P_05=pbinom(4, size=100, prob=0.01)-dbinom(0, size=100, prob=0.01)
> P_05
[1] 0.6305353
> ### Binomial
>
> ## P (X = 1)
>
>
> P_1=dbinom(1, size=100, prob=0.01)
> P_1
[1] 0.3697296
> ## P(X=2)
> P_2=dbinom(2, size=100, prob=0.01)
> P_2
[1] 0.1848648
> ## P (X=3)
> P_3=dbinom(3, size=100, prob=0.01)
> P_3
[1] 0.06099917
>
> ## P (X=4)
> P_4=dbinom(4, size=100, prob=0.01)
> P_4
[1] 0.01494171
>
> Binomial=c(P_1, P_2, P_3, P_4)
>
>
>
> ### Poisson
> ## P (X = 1)
>
>
> PP_1=dpois(1, lambda=1)
> PP_1
[1] 0.3678794
> ## P(X=2)
> PP_2=dpois(2, lambda=1)
> PP_2
[1] 0.1839397
> ## P (X=3)
> PP_3=dpois(3, lambda=1)
> PP_3
[1] 0.06131324
>
> ## P (X=4)
> PP_4=dpois(4, lambda=1)
> PP_4
[1] 0.01532831
>
> Poisson=c(PP_1, PP_2, PP_3, PP_4)
>
>
> i=seq(1,4,1)
>
> cbind(i, Binomial, Poisson)
i Binomial Poisson
[1,] 1 0.36972964 0.36787944
[2,] 2 0.18486482 0.18393972
[3,] 3 0.06099917 0.06131324
[4,] 4 0.01494171 0.01532831
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.