I have written the following code:
n <- 5
lambda <- 2
randomNumbers <- rpois(n, lambda)
prob <- dpois(randomNumbers, lambda)
Is my code correct thus far?
How can I find the expected values of 5 Poisson values?
eX <- mean(randomNumbers)
or,
weighted.mean(randomNumbers, prob)
n <- 5
lambda <- 2
randomNumbers <- rpois(n, lambda)
# estimate of P(X = 0), for example
mean(randomNumbers == 0)
# estimate of E[X]
mean(randomNumbers)