Expand description
crate::probability → distributional primitives now in gam-math.
Structs§
- Weighted
ChiSquare Term - One
λ_j · χ²_{h_j}term of a linear combination of independent chi-squares, with the weight’s SIGN and the term’s degrees of freedom both carried explicitly.
Enums§
- Exact
Binary64 SumSign Error - Why
exact_binary64_sum_signcould not classify its finite exact sum.
Constants§
- IMHOF_
MAX_ PANELS - Cost backstop on the Imhof panel sweep.
- WEIGHTED_
CHI_ SQUARE_ TOLERANCE - Default absolute accuracy
weighted_chi_square_sfcertifies on its Imhof truncation. It is four orders below the smallest probability any consumer of a survival function resolves in practice and eleven below one, so the truncation is never the term that limits a reported tail.
Functions§
- beta_
quantile - Quantile (inverse CDF) of a Beta distribution with shape parameters
a > 0andb > 0at probabilityp: the valuex in [0, 1]withI_x(a, b) = p, whereIis the regularized incomplete beta. - chi_
square_ sf - Chi-squared survival probability
P(X_ν > statistic). - cone_
boundary_ log_ factor - Log of the standardized one-sided truncated-Gaussian boundary factor for the constrained-LAML cone correction (gam#2306 §4).
- cone_
boundary_ log_ factor_ and_ derivatives cone_boundary_log_factortogether with its exact partial derivatives in the standardized arguments — the pieces the outer ρ-gradient chains through(μ̃, h̃, s)(ρ)(gam#2306 §4 “the g-factors differentiate in closed form”). Withξ = b − aand the Mills ratioλ(ξ) = φ(ξ)/Φ(ξ):- erfcx_
nonnegative - Scaled complementary error function
erfcx(x) = exp(x²) · erfc(x), specialized to the closed domainx ∈ [0, +∞]. - exact_
binary64_ sum_ sign - Exact sign of a finite binary64 sum, independent of order and cancellation.
- fisher_
snedecor_ sf - Fisher-Snedecor survival probability
P(F_{d1,d2} > statistic). - log1mexp_
positive - Computes
log(1 - exp(-a))fora >= 0without cancellation. - normal_
cdf - Standard normal CDF Phi(x) evaluated via the exact special-function identity
- normal_
logcdf - Numerically stable
ln Φ(x)for the standard normal CDF. Forx ≥ 0, evaluatesln(1 - 0.5 erfc(x/sqrt(2)))withln_1p, retaining the small negative result afterΦ(x)itself rounds to one. Forx < 0, rewritesln Φ(x) = −u² + ln(½·erfcx(u)),u = −x/√2, which preserves digits throughout the representable left tail without a probability floor. Returns the corresponding IEEE limit at infinities and propagatesNaN. - normal_
logcdf_ derivatives - Stable value and first four derivatives of
ln Φ(x). - normal_
logsf - Numerically stable
ln(1 − Φ(x)) = ln Φ(−x)for the standard normal survival function. Delegates tonormal_logcdf(-x)so the deep-right tail benefits from the sameerfcx-based representation. - normal_
pdf - Standard normal PDF phi(x).
- normal_
sf - Standard normal survival probability
P(Z > x). - normal_
two_ sided_ probability - Two-sided standard-normal probability
P(|Z| ≥ |z|). - signed_
log_ sum_ exp - Numerically stable signed log-sum-exp. Given pairs
(log|aⱼ|, sign(aⱼ))(withsigns[j] ∈ {−1, 0, +1}), returns(log|S|, sign(S))forS = Σⱼ signs[j]·exp(log_mags[j]). Positive and negative magnitudes are first reduced together, after one common log-space rescaling, with a twofold compensated sum. This avoids rounding each same-sign subtotal throughlnandexpbefore subtracting them — an avoidable loss that is amplified in cancellation-conditioned derivative cumulants. If the compensated residual lies inside its forward-error bound, the function instead uses the two-subtotal log-domain differencelog(|p − n|) = max(log p, log n) + log1mexp(|log p − log n|). That branch retains differences between two input logs even when their exponentials round to the samef64. When all signs are zero or all magnitudes are−∞, returns(NEG_INFINITY, 0.0). - signed_
probit_ logcdf_ and_ mills_ ratio - Joint evaluation of
ln Φ(x)and the Mills-ratio analogueφ(x) / Φ(x), signed for the symmetric branch. Used by the latent probit families where the inverse-link gradient needs the ratio and the likelihood needs the log-CDF on the samex; computing both in one call shares theerfcxevaluation that dominates the cost in the deep tail. - signed_
weighted_ chi_ square_ sf - Survival probability
P(Σ_j λ_j χ²_{h_j} > statistic)for independent central chi-squares, with weights of EITHER SIGN, atWEIGHTED_CHI_SQUARE_TOLERANCE. - signed_
weighted_ chi_ square_ sf_ to_ tolerance signed_weighted_chi_square_sfat a caller-chosen absolute accuracy, returning the bound actually achieved alongside the value.- standard_
normal_ quantile - Standard normal quantile Φ⁻¹(p) using Acklam’s rational approximation.
- standard_
normal_ quantile_ from_ log_ cdf - Standard normal quantile from
log_p = ln Φ(x). - student_
t_ sf - Student-t survival probability
P(T_ν > t). - student_
t_ two_ sided_ probability - Two-sided Student-t probability
P(|T_ν| ≥ |t|). - weighted_
chi_ square_ sf - Survival probability
P(Σ_j w_j Z_j² > statistic)for independent standard normalsZ_jand non-negative weightsw. - weighted_
chi_ square_ sf_ to_ tolerance weighted_chi_square_sf_with_boundat a caller-chosen absolute accuracy.- weighted_
chi_ square_ sf_ with_ bound weighted_chi_square_sftogether with the certified absolute bound on its own truncation error, so a consumer (or a test) can see the accuracy rather than trust it.