Expand description
Numerical stability improvements
§Numerical Stability Improvements
This module provides numerically stable implementations of common algorithms that are prone to precision loss, overflow, or catastrophic cancellation.
§Features
- Stable summation algorithms (Kahan, pairwise, compensated)
- Robust variance and standard deviation calculations
- Overflow-resistant multiplication and exponentiation
- Stable trigonometric range reduction
- Robust normalization techniques
- Improved root finding with bracketing
- Stable matrix condition number estimation
Structs§
- Kahan
Sum - Kahan summation algorithm for accurate floating-point summation
- Welford
Variance - Welford’s online algorithm for computing variance
Enums§
- Matrix
Norm - Matrix norm types
Traits§
- Stable
Computation - Trait for numerically stable computations
Functions§
- binomial_
stable - Stable computation of binomial coefficients
- condition_
number_ estimate - Condition number estimation using 1-norm
- cross_
entropy_ stable - Cross entropy loss with numerical stability
- expm1_
stable - Stable computation of exp(x) - 1 for small x
- factorial_
stable - Numerically stable factorial computation
- hypot_
stable - Stable computation of sqrt(x² + y²) avoiding overflow
- log1p_
stable - Stable computation of log(1 + x) for small x
- log_
sigmoid_ stable - Numerically stable log-sigmoid function
- log_
sum_ exp - Log-sum-exp trick for stable computation of log(sum(exp(x)))
- mulmod_
stable - Stable computation of (a*b) % m avoiding overflow
- neumaier_
sum - Neumaier summation algorithm (improved Kahan summation)
- pairwise_
sum - Pairwise summation algorithm
- reduce_
angle - Stable angle reduction for trigonometric functions
- sigmoid_
stable - Numerically stable sigmoid function
- stable_
mean - Stable mean calculation using compensated summation
- stable_
norm_ 2 - Stable L2 norm computation avoiding overflow/underflow
- stable_
softmax - Stable softmax computation
- stable_
variance - Stable two-pass algorithm for variance calculation
- stablematrix_
norm - Stable matrix norm computation