Use R to simulate 10 observations from a Poisson lambda 1 d
Use R to simulate 10 observations from a Poisson (lambda = 1) distribution. Calculate the sum S_10 = X_i and store it. Repeat it. Repeat this 10,000 times so that you have 10,000 simulated values of S_10. What should the distribution of S_10 be? Does the distribution of your 10,000 simulated S_10 values agree with this? Find the mean of 10000 S_10 values. Compare it to the theoretical value.
Solution
data=matrix(0,10000,10)
for(i in 1:10)
{
data[,i]=rpois(10000,1)
}
data
s=matrix(0,10000,1)
for(i in 1:10000)
s[i,]=sum(data[i,])
s
a)The distribution of S10 should be Poisson(10)
b) Theoretically,Mean of 10000 s10 values=10 and for this generated data=9.9837(>mean(s))
c)Theoretically,variance of 10000 s10 values=10 and for this generated data=10.01124 (>var(s))
