#numeric #stable #exp #ln #reference #f64 #numerically

logsumexp

Numerically stable computation of log-sum-exp using a 1-pass algorithm

1 unstable release

0.1.0 Jul 25, 2023

#1237 in Math

MIT/Apache

23KB
334 lines

logsumexp

Description

Provides two traits:

  • LogAddExp, which provides a numerically stable evaluation of ln(exp(a) + exp(b)), utilizing ln_1p_exp from the lnexp crate. Implementations are provided for for f64 and f32 (and their respective references).
  • LogSumExp, which provides a numerically stable, 1-pass (online) algorithm for evaluation of LogSumExp with correct handling of +/- infinity and nan. Implementations are provided iterators which produce Items of f64 or f32 (and for respective references).

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Citations

Dependencies

~33KB