# #字符串 #香农 #计算

shannon-entropy

一个简单的库,用于计算字符串的香农熵

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 #香农

Download history 7/week @ 2024-03-10 1/week @ 2024-03-17 11/week @ 2024-03-31 1/week @ 2024-04-07 3/week @ 2024-05-19 1/week @ 2024-05-26 10/week @ 2024-06-16 54/week @ 2024-06-23

每月64次下载

MIT/Apache

8KB
54

Build Status Coverage Status

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);
  }  
}

无运行时依赖