Expand description
crate::probability → distributional primitives now in gam-math.
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. - 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, +∞]. - 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).
- 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 reduced separately with the standard log-sum-exp trick (subtract the max, sum, log, add back); the two partial sums are then combined vialog(|p − n|) = max(log p, log n) + log1mexp(|log p − log n|), preserving accuracy even whenp ≈ n(catastrophic cancellation regime). 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. - 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).