probability_to_friendly_string

Crates.ioprobability_to_friendly_string
lib.rsprobability_to_friendly_string
version0.3.0
sourcesrc
created_at2019-11-06 03:47:31.149569
updated_at2020-11-10 03:07:17.868706
descriptionMake probabilities more intuitive by converting them to odds. (i.e. 72.3% becomes "5 in 7")
homepagehttps://github.com/gregstoll/probabilityToFriendlyString
repository
max_upload_size
id178507
size14,157
Greg Stoll (gregstoll)

documentation

README

Published as probability_to_friendly_string crate.

Requires Ruby 2018 edition

Usage:

use probability_to_friendly_string::FriendlyProbability;

let friendly = FriendlyProbability::from_probability(0.723);
assert_eq!(5, friendly.numerator());
assert_eq!(7, friendly.denominator());
assert_eq!("Good chance", friendly.friendly_description());
assert_eq!("5 in 7", friendly.friendly_string());

let friendly = FriendlyProbability::from_probability(0.999);
assert_eq!(">99 in 100", friendly.friendly_string());

let friendly = FriendlyProbability::from_probability(0.001);
assert_eq!("<1 in 100", friendly.friendly_string());

Note that passing a value less than 0.0 or greater than 1.0 to FriendlyProbability::from_probability will panic.

Commit count: 0

cargo fmt