pub fn ln_add_exp(self, other: LogProb) -> LogProb {
        if other == Self::ln_zero() {
            // do nothing
            self
        } else {
            let (mut p0, mut p1) = (self, other);
            if p1 > p0 {
                mem::swap(&mut p0, &mut p1);
            }
            if p0 == Self::ln_zero() {
                Self::ln_zero()
            } else if *p0 == f64::INFINITY {
                LogProb(f64::INFINITY)
            } else {
                p0 + LogProb((p1 - p0).fastexp().ln_1p())
            }
        }
    }
/// Numerically stable addition of probabilities in log-space.
Numerically stable addition of probabilities in log-space.
Numerically stable addition of probabilities in log - space .
pub fn ln_add_exp(self, other: LogProb) -> LogProb {
        if other == Self::ln_zero() {
            // do nothing
            self
        } else {
            let (mut p0, mut p1) = (self, other);
            if p1 > p0 {
                mem::swap(&mut p0, &mut p1);
            }
            if p0 == Self::ln_zero() {
                Self::ln_zero()
            } else if *p0 == f64::INFINITY {
                LogProb(f64::INFINITY)
            } else {
                p0 + LogProb((p1 - p0).fastexp().ln_1p())
            }
        }
    }
pub fn ln_add_exp ( self , other : LogProb ) -> LogProb { if other == Self :: ln_zero ( ) { // do nothing self } else { let ( mut p0 , mut p1 ) = ( self , other ) ; if p1 > p0 { mem :: swap ( & mut p0 , & mut p1 ) ; } if p0 == Self :: ln_zero ( ) { Self :: ln_zero ( ) } else if * p0 == f64 :: INFINITY { LogProb ( f64 :: INFINITY ) } else { p0 + LogProb ( ( p1 - p0 ) . fastexp ( ) . ln_1p ( ) ) } } }
Numerically stable addition of probabilities in log-space.
Numerically stable addition of probabilities in log - space .
self
other
LogProb
self
other
LogProb