pub fn from<K, KS>(ts: KS) -> Model<K>
where
    K: ModelKey,
    KS: std::iter::IntoIterator<Item = K>,
{
    let mut m = Model::<K>(HashMap::new());
    let mut d: i64 = 0;
    for t in ts {
        let s = m.0.entry(t).or_insert(Stats { f: 0, p: 0.0 });
        (*s).f += 1;
        d += 1;
    }
    for s in m.0.values_mut() {
        (*s).p = ((*s).f as f64) / (d as f64);
    }
    m
}
/// Generate a zero order model from the given [`ModelKey`] stream.
Generate a zero order model from the given [`ModelKey`] stream.
Generate a zero order model from the given [ ` ModelKey ` ] stream .
pub fn from<K, KS>(ts: KS) -> Model<K>
where
    K: ModelKey,
    KS: std::iter::IntoIterator<Item = K>,
{
    let mut m = Model::<K>(HashMap::new());
    let mut d: i64 = 0;
    for t in ts {
        let s = m.0.entry(t).or_insert(Stats { f: 0, p: 0.0 });
        (*s).f += 1;
        d += 1;
    }
    for s in m.0.values_mut() {
        (*s).p = ((*s).f as f64) / (d as f64);
    }
    m
}
pub fn from < K , KS > ( ts : KS ) -> Model < K > where K : ModelKey , KS : std :: iter :: IntoIterator < Item = K > , { let mut m = Model :: < K > ( HashMap :: new ( ) ) ; let mut d : i64 = 0 ; for t in ts { let s = m . 0 . entry ( t ) . or_insert ( Stats { f : 0 , p : 0.0 } ) ; ( * s ) . f += 1 ; d += 1 ; } for s in m . 0 . values_mut ( ) { ( * s ) . p = ( ( * s ) . f as f64 ) / ( d as f64 ) ; } m }
Generate a zero order model from the given [`ModelKey`] stream.
Generate a zero order model from the given [ ` ModelKey ` ] stream .
ts
KS
ts
KS