计算 R 中四个连续随机变量的并集概率

Compute probability of union set of four continuous random variables in R

我有四个自变量 X1, X2, X3, X4 服从标准正态分布。我想计算P(X1 > A | X2 > A | X3 > A | X4 > A)的概率。我在 R 中编写了一个函数,它可以正确计算 A 的任何大于 0 的值的概率,但是对于任何小于 0 的值,结果都很小:

prob_union_greater <- function(x){ 
   (1 - pnorm(x))*4 - 6*((1 - pnorm(x))^2) + 3*((1 - pnorm(x))^3) - ((1 - pnorm(x))^4)  
} 

我尝试为 P(X1 < A | X2 < A | X3 < A | X4 < A) 的情况编写一个类似的函数,但在这里我遇到了相反的问题:对于 A 的负值有效,对于正值无效。

prob_union_smaller <- function(x){
   pnorm(x)*4 - 6*(pnorm(x)^2) + 3*(pnorm(x)^3) - (pnorm(x)^4)  
}

我在这里错过了什么?

您可以试试下面的代码

prob_union_greater <- function(x) {
  p <- pnorm(x, lower.tail = FALSE)
  4 * p - 6 * p^2 + 4 * p^3 - p^4
}

prob_union_smaller <- function(x) {
  p <- pnorm(x)
  4 * p - 6 * p^2 + 4 * p^3 - p^4
}

你会得到

> prob_union_greater(1)
[1] 0.4989328

> prob_union_smaller(1)
[1] 0.9993664

我认为你的函数可以更简洁地写成:

prob_union_greater <- function(x) (1 - pnorm(x)) * sum(pnorm(x)^(0:3))
prob_union_smaller <- function(x) prob_union_greater(-x)

这给了我们:

prob_union_greater(-1)
#> [1] 0.9993664

prob_union_greater(0)
#> [1] 0.9375

prob_union_greater(1)
#> [1] 0.4989328