Skip to main content

logsumexp

Function logsumexp 

Source
pub fn logsumexp(xs: &[f64]) -> f64
Expand description

Compute the log of the sum of exponentials of input elements

Pure Rust translation of scipy.special.logsumexp.

§Definition

For a sequence of real values $\vec{\bm{x}}$, logsumexp is defined as

$$ \ln \sum_{x \in \vec{\bm{x}}} e^x $$

The implementation uses a numerically stable equivalent algorithm which factors out the maximum value.

§Notes

Unlike the SciPy version, this implementation only supports 1-dimensional slices, and doesn’t support complex numbers at the moment.

§See also