[][src]Function shannon_entropy::shannon_entropy

pub fn shannon_entropy(s: &str) -> f32

Calculates the shannon entropy of 's'. https://en.wiktionary.org/wiki/Shannon_entropy

Arguments

  • s - The string slice to calculate entropy for

Examples

It's possible to call the function directly, as in the following example:

let entropy: f32 = shannon_entropy::shannon_entropy("Hi there!");

Alternatively, it is possible to import the ShannonEntropy trait and call the function as if it were a method:

use shannon_entropy::ShannonEntropy;
let entropy = "Hi, there!".entropy();