fn generate_flip_rates(stats: &[Entry])
{
    // Store numerator and denominator, per delay.
    let mut flip_rates: HashMap<usize, (usize, usize)> = HashMap::new();

    // Collect data.
    for entry in stats.iter() {
        if !flip_rates.contains_key(&entry.delay) {
            flip_rates.insert(entry.delay, (0, 0));
        }
        let (num, denom) = flip_rates.get_mut(&entry.delay).unwrap();
        *num += entry.bit_count;
        *denom += TESTED_BITS;
    }

    // Sort it.
    let mut flip_rates_vec = flip_rates
        .iter()
        .map(|(&delay, (num, denom))| (delay, *num as f64 / *denom as f64))
        .collect::<Vec<(usize, f64)>>();
    flip_rates_vec.sort_by(|(a, _), (b, _)| a.cmp(b));

    // Print it.
    println!("{}", flip_rates_vec.iter().map(|(delay, _)| delay.to_string()).collect::<Vec<String>>().join(","));
    println!("{}", flip_rates_vec.iter().map(|(_, frac)| frac.to_string()).collect::<Vec<String>>().join(","));
}
// Generate a very simple table of average bit flip rates per decay period.
Generate a very simple table of average bit flip rates per decay period.
Generate a very simple table of average bit flip rates per decay period .
fn generate_flip_rates(stats: &[Entry])
{
    // Store numerator and denominator, per delay.
    let mut flip_rates: HashMap<usize, (usize, usize)> = HashMap::new();
    // Collect data.
    for entry in stats.iter() {
        if !flip_rates.contains_key(&entry.delay) {
            flip_rates.insert(entry.delay, (0, 0));
        }
        let (num, denom) = flip_rates.get_mut(&entry.delay).unwrap();
        *num += entry.bit_count;
        *denom += TESTED_BITS;
    }
    // Sort it.
    let mut flip_rates_vec = flip_rates
        .iter()
        .map(|(&delay, (num, denom))| (delay, *num as f64 / *denom as f64))
        .collect::<Vec<(usize, f64)>>();
    flip_rates_vec.sort_by(|(a, _), (b, _)| a.cmp(b));
    // Print it.
    println!("{}", flip_rates_vec.iter().map(|(delay, _)| delay.to_string()).collect::<Vec<String>>().join(","));
    println!("{}", flip_rates_vec.iter().map(|(_, frac)| frac.to_string()).collect::<Vec<String>>().join(","));
}
fn generate_flip_rates ( stats : & [ Entry ] ) { // Store numerator and denominator, per delay. let mut flip_rates : HashMap < usize , ( usize , usize ) > = HashMap :: new ( ) ; // Collect data. for entry in stats . iter ( ) { if ! flip_rates . contains_key ( & entry . delay ) { flip_rates . insert ( entry . delay , ( 0 , 0 ) ) ; } let ( num , denom ) = flip_rates . get_mut ( & entry . delay ) . unwrap ( ) ; * num += entry . bit_count ; * denom += TESTED_BITS ; } // Sort it. let mut flip_rates_vec = flip_rates . iter ( ) . map ( | ( & delay , ( num , denom ) ) | ( delay , * num as f64 / * denom as f64 ) ) . collect :: < Vec < ( usize , f64 ) > > ( ) ; flip_rates_vec . sort_by ( | ( a , _ ) , ( b , _ ) | a . cmp ( b ) ) ; // Print it. println ! ( " " flip_rates_vec iter ( ) map ( ( delay ) delay to_string ( ) ) collect Vec String ( ) join ( " " ) ) ; println ! ( " " flip_rates_vec iter ( ) map ( ( frac ) frac to_string ( ) ) collect Vec String ( ) join ( " " ) ) ; }
Generate a very simple table of average bit flip rates per decay period.
Generate a very simple table of average bit flip rates per decay period .
stats
&[Entry]
stats
&[Entry]