Crates.io | entropiter |
lib.rs | entropiter |
version | 0.2.1 |
source | src |
created_at | 2022-03-14 15:40:47.1897 |
updated_at | 2022-03-14 21:58:40.589514 |
description | A no-dep iterator-compatible frequency and Shannon entropy calculator |
homepage | |
repository | https://github.com/Herbstein/entropiter |
max_upload_size | |
id | 549933 |
size | 8,777 |
Easily calculate the frequency and probability of symbol occurrence in an iterator, and effortlessly calculate the entropy.
To use this library you only need an iterator containing the symbol of your choice, and the choice of histogram backing store to accumulate into. The generic backing stores available are BTreeMapHistogram
and HashMapHistogram
, while for u8
symbols ByteHistogram
is also available.
use entropiter::{FrequencyIteratorExt, HashMapHistogram};
fn main() {
let shannon_entropy = "shannon".chars().shannon::<HashMapHistogram<_>>().entropy();
println!("entropy: {}", shannon_entropy);
}