* Winitzki's approximation for the inverse error function, accurate to * ~2e-3 relative over (-1, 1). Used as the Newton seed for `erfInv()` and * `bigErfInv()`.
(x: number)
| 311 | * for real a > 0, b > 0 and 0 ≤ x ≤ 1. Returns NaN outside that domain, and |
| 312 | * the exact endpoints 0 (x=0) and 1 (x=1). |
| 313 | */ |
| 314 | export function betaRegularized(x: number, a: number, b: number): number { |
| 315 | if (Number.isNaN(x) || Number.isNaN(a) || Number.isNaN(b)) return NaN; |
| 316 | if (a <= 0 || b <= 0 || x < 0 || x > 1) return NaN; |
| 317 | if (x === 0) return 0; |
| 318 | if (x === 1) return 1; |
| 319 | const bt = Math.exp( |
| 320 | gammaln(a + b) - |
| 321 | gammaln(a) - |