entropiter

Crates.ioentropiter
lib.rsentropiter
version0.2.1
sourcesrc
created_at2022-03-14 15:40:47.1897
updated_at2022-03-14 21:58:40.589514
descriptionA no-dep iterator-compatible frequency and Shannon entropy calculator
homepage
repositoryhttps://github.com/Herbstein/entropiter
max_upload_size
id549933
size8,777
Rasmus Larsen (Herbstein)

documentation

README

Entropiter

Easily calculate the frequency and probability of symbol occurrence in an iterator, and effortlessly calculate the entropy.

Usage

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.

Example

use entropiter::{FrequencyIteratorExt, HashMapHistogram};

fn main() {
    let shannon_entropy = "shannon".chars().shannon::<HashMapHistogram<_>>().entropy();
    println!("entropy: {}", shannon_entropy);
}
Commit count: 8

cargo fmt