学生的 t 分布 CDF R 基础文档

lui*_*gom 9 statistics r function probability

在学生 t 分布累积分布函数的上下文中,R 版本 4.3.1 的?dt文档强调了以下结果:

然而,在尝试验证该公式的准确性时,出现了不一致的情况,如以下代码片段所示:

v <- 5
t <- -1

## Student's t-distribution cumulative distribution function
pt(q = t, df = v, lower.tail = TRUE, ncp = 0)
#> [1] 0.1816087

## Application of the theorical result where there is a discrepancy 
## based on what is mentioned in R Version 4.3.1's ?dt documentation
1 - pbeta(q = v / (v + t^2), shape1 = v/2, shape2 = 1/2, 
          ncp = 0,lower.tail = TRUE)
#> [1] 0.6367825
Run Code Online (Sandbox Code Playgroud)

创建于 2023-10-09,使用reprex v2.0.2

此问题引发了有关文档准确性的问题。在向 R 项目报告潜在错误之前,我正在寻求澄清以确定问题是否出在文档本身。这个查询涉及到一个理论概念,详细解释可以在这里找到

Sté*_*ent 7

嗯,看起来像是一个错误。这是一个有效的身份:

v <- 5
t <- -1

## Student's t-distribution cumulative distribution function
pt(q = t, df = v, lower.tail = TRUE, ncp = 0)
#> [1] 0.1816087

x = (t + sqrt(t * t + v)) / (2.0 * sqrt(t * t + v))
pbeta(q = x, shape1 = v/2, shape2 = v/2, ncp = 0, lower.tail = TRUE)
#> [1] 0.1816087
Run Code Online (Sandbox Code Playgroud)

另一种更接近 R 文档的说法:

pbeta(q = v / (v + t^2), shape1 = v/2, shape2 = 1/2, 
            ncp = 0,lower.tail = TRUE) / 2
#> [1] 0.1816087
Run Code Online (Sandbox Code Playgroud)