6 个版本 (1 个稳定版本)
使用旧的 Rust 2015
1.0.0 | 2020年3月5日 |
---|---|
0.2.1 | 2020年3月5日 |
0.2.0 | 2016年3月9日 |
0.1.2 | 2016年3月9日 |
#2 in #香农
每月64次下载
8KB
54 行
shannon-entropy
一个用于计算字符串香农熵的 Rust 库。
用法
可在 crates.io 上使用
将以下内容添加到您的 Cargo.toml 文件中
[dependencies]
shannon-entropy = "0.2"
示例
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);
}
}