fix(stats): hold the Student-t tails past t-squared overflow

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-09-27 17:03:36 +02:00
parent 2f9358c512
commit 275de79123
6 changed files with 113 additions and 10 deletions
+8 -1
View File
@@ -304,7 +304,14 @@ func NoncentralTCDF(t float64, df int, delta float64) (float64, error) {
magnitude = -t
shift = -delta
}
x := magnitude * magnitude / (magnitude*magnitude + float64(df))
magnitude2 := magnitude * magnitude
x := magnitude2 / (magnitude2 + float64(df))
if math.IsInf(magnitude2, 1) {
// A finite t whose square overflows drove the quotient through
// Inf/Inf into a NaN the incomplete beta refused under its own
// name. The beta argument's limit there is exactly 1.
x = 1
}
if x == 0 {
// t = 0: the value collapses to Φ(−δ) exactly.
return NormalCDF(-delta), nil