Skip to content

A rust library to calculate the shannon entropy of a string.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

insanitybit/shannon-entropy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

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

About

A rust library to calculate the shannon entropy of a string.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages