6 releases (1 stable)
Uses old Rust 2015
1.0.0 | Mar 5, 2020 |
---|---|
0.2.1 | Mar 5, 2020 |
0.2.0 | Mar 9, 2016 |
0.1.2 | Mar 9, 2016 |
#2 in #shannon
8KB
54 lines
shannon-entropy
A rust library to calculate the Shannon entropy of a string.
Usage
Available on crates.io
Add this to your Cargo.toml
[dependencies]
shannon-entropy = "0.2"
Example
fn main() {
let test_strings = vec![
("hello world", 2.8453512),
("hello worldd", 2.8553884),
("a", 0.0),
("", 0.0),
];
for (test, answer) in test_strings {
let entropy: f32 = shannon_entropy(test);
assert_eq!(entropy, answer);
}
}