pub trait LogSumExp {
    type Output;

    fn ln_sum_exp(self) -> Self::Output;
}
Expand description

A trait for computing ln_sum_exp

Required Associated Types

The result of the computation

Required Methods

Compute the log of the sum of exponentials

This computes the same value value as self.map(|v| v.exp()).sum().ln() but in a more numerically stable way then computing it using that formula. This is also slightly more stable then doing self.reduce(|a, b| a.ln_add_exp(b)).

Examples
use logaddexp::LogSumExp;
[1.0, 2.0, 4.0].into_iter().ln_sum_exp();

Implementors