## sheet 6, ex. 3 (a) p <- 1/117411*c(103705,11632,1767,255,44,6,2) k <- 0:6 ev <- p %*% k variance <- (k-ev)^2 %*% p ev variance ## Since the expected value is less than the variance of the ## empirical distribution function, the sample is probably ## not Poisson distributed. ## ex. 3 (b) p dpois(k, ev) dpois(k, variance) ## ex. 3 (c) pnegbinom <- function(k, alpha, p) { x <- (1-p)^alpha if (k == 0) { return(x) } a <- p b <- (alpha-1)*a for (i in 1:k) { x <- (a+b/i)*x } return(x) } for (i in 0:6) { cat(pnegbinom(i, 0.625507, 0.180254)," ") }