######################################################################### ## This function returns the value of the probability density function ## ## of a mixed Poisson distributed random variable with the parameters ## ## given in exercise 1, sheet #5 ## ######################################################################### pdf_N <- function(k) { lambda <- c(60,35,16,12,6) p <- c(0.05,0.2,0.4,0.25,0.1) sum <- NULL for (i in 1:length(k)) { temp <- exp(-lambda)*lambda^k[i]/factorial(k[i]) sum <- c(sum,t(p)%*%temp) } return(sum) } ## Example 1: value of the pdf at k=1 pdf_N(1) ## Example 2: value of the pdf at k=1,3,5 k <- c(1,3,5) pdf_N(k)