fn log_sum_exp(values: &[f64]) -> f64 {
    use std::f64;
    let max_val = values.iter().fold(f64::NEG_INFINITY, |a, &b| a.max(b));
    let sum_exp = values.iter().fold(0.0, |a, &b| a + (b - max_val).exp());
    sum_exp.ln() + max_val
}
/// Compute the logsumexp of the values
/// If values is empty, returns NaN
Compute the logsumexp of the values
If values is empty, returns NaN
Compute the logsumexp of the values If values is empty returns NaN
fn log_sum_exp(values: &[f64]) -> f64 {
    use std::f64;
    let max_val = values.iter().fold(f64::NEG_INFINITY, |a, &b| a.max(b));
    let sum_exp = values.iter().fold(0.0, |a, &b| a + (b - max_val).exp());
    sum_exp.ln() + max_val
}
fn log_sum_exp ( values : & [ f64 ] ) -> f64 { use std :: f64 ; let max_val = values . iter ( ) . fold ( f64 :: NEG_INFINITY , | a , & b | a . max ( b ) ) ; let sum_exp = values . iter ( ) . fold ( 0.0 , | a , & b | a + ( b - max_val ) . exp ( ) ) ; sum_exp . ln ( ) + max_val }
Compute the logsumexp of the values
If values is empty, returns NaN
Compute the logsumexp of the values If values is empty returns NaN
values
&[f64]