Skip to main content

entropy

Function entropy 

Source
pub fn entropy(values: &[f64], bins: usize) -> f64
Expand description

Compute Shannon entropy of a set of continuous values.

Discretizes values into bins equal-width bins, then computes: H(X) = -Σ p(x) log₂ p(x)

High entropy indicates unpredictability; low entropy indicates regular patterns.

§Arguments

  • values - The continuous values to analyze
  • bins - Number of bins for discretization (typically 10–50)

§Returns

Entropy in bits. Returns 0.0 for empty input.

§Reference

Shannon (1948), “A Mathematical Theory of Communication”