Expand description
Traits§
- LogAdd
Exp - A trait which, for the type on which it is implemented,
provides numerically-stable evaluation of
ln(exp(a) + exp(b))
. The implementations provided forf64
(and&f64
) andf32
(and&f32
) utilizeln_1p_exp
for maximum stability. - LogSum
Exp - A trait for computing the log of the sum of exponentials of a sequence
in a numerically-stable manner, using a 1-pass (online) algorithm based on
Milakov, Maxim, and Natalia Gimelshein. “Online normalizer calculation for softmax.” (2018).
In contrast to the version described in the reference, this algorithm correctly handles +/-infinity and
nan
values at any point in the sequence.