在R中找到n个泊松值的期望

时间:2019-03-08 03:56:43

标签: r statistics probability mean poisson

  

enter image description here

我写了以下代码:

n <- 5
lambda <- 2
randomNumbers <- rpois(n, lambda)
prob <- dpois(randomNumbers, lambda)

到目前为止,我的代码是否正确?

如何找到5个泊松值的期望值?

eX <- mean(randomNumbers)

weighted.mean(randomNumbers, prob)

1 个答案:

答案 0 :(得分:2)

n <- 5
lambda <- 2
randomNumbers <- rpois(n, lambda)
# estimate of P(X = 0), for example
mean(randomNumbers == 0)
# estimate of E[X]
mean(randomNumbers)