#stable #exp #overflow #value #log #logsumexp #ln-sum-exp

logaddexp

stable implementations of logaddexp and logsumexp

4 releases

0.1.3 Feb 20, 2024
0.1.2 Mar 17, 2023
0.1.1 Oct 22, 2022
0.1.0 Oct 21, 2022

#330 in Debugging

Download history 1/week @ 2024-01-21 10/week @ 2024-01-28 43/week @ 2024-02-04 158/week @ 2024-02-11 227/week @ 2024-02-18 78/week @ 2024-02-25 42/week @ 2024-03-03 75/week @ 2024-03-10 62/week @ 2024-03-17 86/week @ 2024-03-24 284/week @ 2024-03-31 262/week @ 2024-04-07 259/week @ 2024-04-14 294/week @ 2024-04-21 274/week @ 2024-04-28 215/week @ 2024-05-05

1,065 downloads per month
Used in cfr

MIT license

9KB
129 lines

logaddexp-rs

crates.io docs license build

Stable implementations of logaddexp and logsumexp in rust. Computing log(sum_i(exp(v_i))) for more than one value can esily result in overflow. This crate provies implementations for two (ln_add_exp) and many (ln_sum_exp) that are more stable (less prone to overfloe) than doing that computation naively.

Usage

Run

$ cargo add logadexp

Then import the trait you want to use and call the function on the appropriate types

use logaddexp::LogAddExp;

f64::ln_add_exp(..., ...);
use logaddexp::LogSumExp;

[...].into_iter().ln_sum_exp();

Dependencies

~155KB