【问题标题】:How to use normal distribution to calculate probability that one player will score more points than another in a game?如何使用正态分布来计算一个玩家在游戏中得分比另一个玩家多的概率?
【发布时间】:2021-10-21 13:18:30
【问题描述】:

请帮我在 R 中解决这个问题:

Alex 的平均得分预计为 2 分,正态分布,SD 为 2 分。 Bob 的平均得分为 1 分,正态分布,SD 为 3 分。

Alex 得分高于 Bob 的概率是多少?

【问题讨论】:

标签: r probability


【解决方案1】:

如果你想模拟,使用rnorm函数生成正态分布。

n <- 1000000
Alex <- rnorm(n, 2, 2)
Bob <- rnorm(n, 1, 3)
sum(Alex>Bob)/n

[1] 0.610427

【讨论】:

  • mean(Alex &gt; Bob) 更简单。点赞。
  • @RuiBarradas Jesus。我想念那个。谢谢。
【解决方案2】:

用R代码写的,教科书解决方案是

mu_Alex <- 2
sd_Alex <- 2
mu_Bob <- 1
sd_Bob <- 3

问题要求 P(A > B) = P(A - B > 0)。
令 D = A - B 并计算差值的均值和方差。不要忘记方差是二次算子,所以方差加起来。然后取平方根。

mu_Diff <- mu_Alex - mu_Bob
var_Diff <- sd_Alex^2 + sd_Bob^2
sd_Diff <- sqrt(var_Diff)

转换为标准高斯。 (这不太对,我要转换为标准高斯的是 A - B > 0 中的零)

z_Diff <- (0 - mu_Diff)/sd_Diff

得到上尾,因为我们想要 P(D > 0)。

pnorm(z_Diff, mean = mu_Diff, sd = sd_Diff, lower.tail = FALSE)
#[1] 0.6384329

Park's simulation 与准确值相差不远。

【讨论】:

    猜你喜欢
    • 2021-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-04
    • 2012-10-30
    • 2017-09-14
    • 2022-11-25
    相关资源
    最近更新 更多