1B

x = rgamma(n = 10000,shape = 1, rate = 1/2)
mean(x)
## [1] 2.020502
var(x)
## [1] 4.000041

Yes this does confirm our result from part A.
We got alpha/beta for the mean which is 1/0.5 = 2
And alpha/(beta^2) = 4 for the variance.
Our approximations are very close to these numbers.

3A

s = rpois(10000,5)
mean(s==5)
## [1] 0.1748

3B

x = rpois(100000, 5)
y = 1/100000*sum(x)
y
## [1] 5.00268

3C

n = 10000
x = rpois(n,5)
varX <- (1/n)*(n/(n-1))*(sum((x-mean(x))^2))
varX
## [1] 5.040676