Skip to main content

Module numerical

Module numerical 

Source
Expand description

Numerical utilities for numerically stable computation

Provides compensated summation (Kahan) and other numerical primitives used in training loops and loss computation.

Functions§

kahan_mean
Numerically stable mean computation using Kahan summation
kahan_sum
Kahan compensated summation — reduces floating-point accumulation error from O(n * eps) to O(eps) for n addends.
kahan_sum_f64
Kahan compensated summation for f64 values
kahan_variance
Numerically stable variance computation (two-pass with Kahan)