pub fn with_frequencies<K: ModelKey>(fs: &[(K, u64)]) -> Model<K> {
    let fs: HashMap<K, u64> = fs.to_vec().into_iter().collect();
    let total = fs.values().sum::<u64>() as f64;
    let mut m = Model::<K>(HashMap::new());
    for (t, f) in fs.into_iter() {
        m.0.insert(
            t,
            Stats {
                f,
                p: (f as f64) / total,
            },
        );
    }
    m
}
/// Instantiate a zero order model from the given precomputed frequencies.
///
/// Intended to be used only from unit-tests, to avoid dependence on internal
/// computation of frequencies in [`from()`].
Instantiate a zero order model from the given precomputed frequencies.
Intended to be used only from unit-tests, to avoid dependence on internal
computation of frequencies in [`from()`].
Instantiate a zero order model from the given precomputed frequencies . Intended to be used only from unit - tests to avoid dependence on internal computation of frequencies in [ ` from () ` ] .
pub fn with_frequencies<K: ModelKey>(fs: &[(K, u64)]) -> Model<K> {
    let fs: HashMap<K, u64> = fs.to_vec().into_iter().collect();
    let total = fs.values().sum::<u64>() as f64;
    let mut m = Model::<K>(HashMap::new());
    for (t, f) in fs.into_iter() {
        m.0.insert(
            t,
            Stats {
                f,
                p: (f as f64) / total,
            },
        );
    }
    m
}
pub fn with_frequencies < K : ModelKey > ( fs : & [ ( K , u64 ) ] ) -> Model < K > { let fs : HashMap < K , u64 > = fs . to_vec ( ) . into_iter ( ) . collect ( ) ; let total = fs . values ( ) . sum :: < u64 > ( ) as f64 ; let mut m = Model :: < K > ( HashMap :: new ( ) ) ; for ( t , f ) in fs . into_iter ( ) { m . 0 . insert ( t , Stats { f , p : ( f as f64 ) / total , } , ) ; } m }
Instantiate a zero order model from the given precomputed frequencies.
Instantiate a zero order model from the given precomputed frequencies .
fs
&[(K, u64)]
fs
&[(K, u64)]