Skip to main content

interval_text

Function interval_text 

Source
pub fn interval_text(i: &EconomicsInterval, unit: &str) -> String
Expand description

An interval as every surface spells it: the confidence level (level_text, so that 9750 reads 97.5% and is never rounded into a level the methodology did not declare), then both bounds in the metric’s unit (amount). The bounds of a ratio are reductions, like the value they bracket.

use majordomus_cli::economics::{model::EconomicsInterval, report::interval_text};
let i = EconomicsInterval {
    level_bp: 9750, low: -0.05, high: 0.3, method: "percentile bootstrap".into(),
    resamples: 2000, seed: 7,
};
assert_eq!(interval_text(&i, "ratio"), "97.5%: -5.0% to +30.0%");
let tokens = EconomicsInterval { level_bp: 9500, low: 1200.0, high: 4800.0, ..i };
assert_eq!(interval_text(&tokens, "tokens"), "95%: +1200 tokens to +4800 tokens");