【问题标题】:Finding the expectation of n Poisson values in R在 R 中找到 n 个泊松值的期望
【发布时间】:2019-07-30 02:08:47
【问题描述】:

我写了以下代码:

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

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

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

eX <- mean(randomNumbers)

或者,

weighted.mean(randomNumbers, prob)

【问题讨论】:

  • 泊松随机变量的均值等于 lambda。问题中是否缺少某些内容,应该是 5 个数字的总和还是什么?
  • @Marius,已编辑。

标签: r statistics probability mean poisson


【解决方案1】:
n <- 5
lambda <- 2
randomNumbers <- rpois(n, lambda)
# estimate of P(X = 0), for example
mean(randomNumbers == 0)
# estimate of E[X]
mean(randomNumbers)

【讨论】:

    猜你喜欢
    • 2019-07-05
    • 2020-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-21
    • 1970-01-01
    相关资源
    最近更新 更多