In: Statistics and Probability
set.seed(12345678)
x=rpois(300,3)
State the sample (g1) that you obtained. Do these look like observations of a Poisson random variable with mean λ = 3?
(a) What is the sample mean and sample variance. Are they approximately equal?
(b) Find the frequencies of 0, 1, 2, . . . , 7, and 8 or more.
(c) Construct a Poisson probability histogram with λ = 3 and a relative frequency histogram of the sample on the same graph using part (b). Comment on this graph.
(d) Use α = 0.05 and a chi-square goodness-of-fit test to test whether the sample looks like observations of a Poisson random variable with mean λ = 3.
The R-code is
set.seed(12345678)
x=rpois(300,3)
#a)
mean(x) #mean
var(x) #variance
#Yes, mean and variance are approximately equal to 3
#b)
f=table(x);f
#c)
Prob=c(dpois(0:7,3),1-ppois(7,3))
hist(x,freq=F,breaks=9)
lines(0:8,Prob,col=2)
legend("topright",legend=c("Poisson distribution with lambda = 3 "),fill=2)
#The Poisson distribution is good fit for given sample
#d)
chisq.test(f,p=Prob)
#Here pvalue=0.5073>alpha=0.05 then we fail to reject the null hypothesis and conclude that sample looks like observations of a Poisson random variable with mean λ = 3
The output of the code is
>set.seed(12345678)
>x=rpois(300,3)
>#a)
>mean(x) #mean
[1] 2.893333
>var(x) #variance
[1] 2.563835
>#Yes, mean and variance are approximately equal to 3
>#b)
>f=table(x);f
x
0 1 2 3 4 5 6 7 8
17 38 79 64 54 32 10 4 2
>#c)
>Prob=c(dpois(0:7,3),1-ppois(7,3))
>hist(x,freq=F,breaks=9)
>lines(0:8,Prob,col=2)
>legend("topright",legend=c("Poisson distribution with lambda =
3 "),fill=2)
>#The Poisson distribution is good fit for given sample
>#d)
>chisq.test(f,p=Prob)
Chi-squared test for given probabilities
data: f
X-squared = 7.2746, df = 8, p-value = 0.5073
>#Here pvalue=0.5073>alpha=0.05 then we fail to reject the null hypothesis and conclude that sample looks like observations of a Poisson random variable with mean λ = 3