我写了以下代码:
n <- 5
lambda <- 2
randomNumbers <- rpois(n, lambda)
prob <- dpois(randomNumbers, lambda)
到目前为止我的代码是否正确?
如何找到5个泊松值的预期值?
eX <- mean(randomNumbers)
要么,
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)