#probability #odds #probabilities #friendly #string #intuitive #become

probability_to_friendly_string

Make probabilities more intuitive by converting them to odds. (i.e. 72.3% becomes "5 in 7")

3 releases (breaking)

0.3.0 Nov 10, 2020
0.2.0 Feb 16, 2020
0.1.0 Nov 6, 2019

#489 in Science

MIT license

12KB
179 lines

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.

Dependencies

~10KB