Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/insanitybit/shannon-entropy
A rust library to calculate the shannon entropy of a string.
https://github.com/insanitybit/shannon-entropy
Last synced: 29 days ago
JSON representation
A rust library to calculate the shannon entropy of a string.
- Host: GitHub
- URL: https://github.com/insanitybit/shannon-entropy
- Owner: insanitybit
- License: apache-2.0
- Created: 2016-03-08T23:30:26.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-22T14:40:43.000Z (11 months ago)
- Last Synced: 2024-11-06T22:57:34.483Z (about 1 month ago)
- Language: Rust
- Size: 14.6 KB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/insanitybit/shannon-entropy.png)](https://travis-ci.org/insanitybit/shannon-entropy)
[![](https://meritbadge.herokuapp.com/gsbrs)](https://crates.io/crates/gsbrs)
[![Coverage Status](https://coveralls.io/repos/insanitybit/shannon-entropy/badge.svg?branch=master&service=github)](https://coveralls.io/github/insanitybit/shannon-entropy?branch=master)# shannon-entropy
A rust library to calculate the Shannon entropy of a string.# Usage
Available on crates.ioAdd this to your Cargo.toml
```toml
[dependencies]
shannon-entropy = "0.2"
```# Example
```rust
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);
}
}
```