/// judge a set of notes based on familiarity & novelty balance.
/// range: floats in [0, 1] and lower is better.
judge a set of notes based on familiarity & novelty balance.
range: floats in [0, 1] and lower is better.
judge a set of notes based on familiarity & novelty balance . range : floats in [ 0 1 ] and lower is better .
fn judge_novelty(noteset: &[Frac], memory: &Memory) -> f64 {
    if noteset.len() < 1 {
        panic!("judge_novelty: need at least 1 note");
    }
    let mut familiarity_sum = 0_f64;
    for note in noteset {
        let &familiarity = memory.get(note).unwrap_or(&0_f64);
        familiarity_sum += familiarity;
    }
    let avg_familiarity = familiarity_sum / (noteset.len() as f64);
    let target_familiarity = 0.1_f64;
    let disparity = (target_familiarity - avg_familiarity).abs();
    (1_f64 - 1_f64/disparity.exp()).max(0_f64).min(1_f64)
}
fn judge_novelty ( noteset : & [ Frac ] , memory : & Memory ) -> f64 { if noteset . len ( ) < 1 { panic ! ( " " ) ; } let mut familiarity_sum = 0_f64 ; for note in noteset { let & familiarity = memory . get ( note ) . unwrap_or ( & 0_f64 ) ; familiarity_sum += familiarity ; } let avg_familiarity = familiarity_sum / ( noteset . len ( ) as f64 ) ; let target_familiarity = 0.1_f64 ; let disparity = ( target_familiarity - avg_familiarity ) . abs ( ) ; ( 1_f64 - 1_f64 / disparity . exp ( ) ) . max ( 0_f64 ) . min ( 1_f64 ) }
judge a set of notes based on familiarity & novelty balance.
judge a set of notes based on familiarity & novelty balance .
noteset
&[Frac]
memory
&Memory