/// Create CDF from a vector representing a probability mass function (PMF).
/// The PMF may contain duplicate values the probabilities of which are summed
/// during generation of the CDF.
///
/// Runtime complexity: O(n log n), where n is the number of `entries`.
///
/// # Arguments
///
/// * `entries` - The PMF as a vector of `Entry` objects (values with an associated `LogProb`).
Create CDF from a vector representing a probability mass function (PMF).
The PMF may contain duplicate values the probabilities of which are summed
during generation of the CDF.

Runtime complexity: O(n log n), where n is the number of `entries`.
Create CDF from a vector representing a probability mass function ( PMF ) . The PMF may contain duplicate values the probabilities of which are summed during generation of the CDF . Runtime complexity : O ( n log n ) where n is the number of ` entries ` .
pub fn from_pmf(mut entries: Vec<Entry<T>>) -> Self {
        entries.sort_by(|a, b| a.value.cmp(&b.value));
        let mut inner: Vec<Entry<T>> = Vec::new();
        for mut e in entries {
            let p = inner
                .last()
                .map_or(LogProb::ln_zero(), |e| e.prob)
                .ln_add_exp(e.prob);
            if !inner.is_empty() && inner.last().unwrap().value == e.value {
                inner.last_mut().unwrap().prob = p;
            } else {
                e.prob = p;
                inner.push(e);
            }
        }
        let mut cdf = CDF { inner };
        // cap at prob=1.0 if there are slightly exceeding values due to numerical issues.
        for e in &mut cdf.inner {
            e.prob = e.prob.cap_numerical_overshoot(0.00001);
        }
        cdf
    }
pub fn from_pmf ( mut entries : Vec < Entry < T > > ) -> Self { entries . sort_by ( | a , b | a . value . cmp ( & b . value ) ) ; let mut inner : Vec < Entry < T > > = Vec :: new ( ) ; for mut e in entries { let p = inner . last ( ) . map_or ( LogProb :: ln_zero ( ) , | e | e . prob ) . ln_add_exp ( e . prob ) ; if ! inner . is_empty ( ) && inner . last ( ) . unwrap ( ) . value == e . value { inner . last_mut ( ) . unwrap ( ) . prob = p ; } else { e . prob = p ; inner . push ( e ) ; } } let mut cdf = CDF { inner } ; // cap at prob=1.0 if there are slightly exceeding values due to numerical issues. for e in & mut cdf . inner { e . prob = e . prob . cap_numerical_overshoot ( 0.00001 ) ; } cdf }
Create CDF from a vector representing a probability mass function (PMF).
Create CDF from a vector representing a probability mass function ( PMF ) .
entries
Vec<Entry<T>>