---
library: "brainference"
slug: "ShannonEntropy"
name: "ShannonEntropy"
ref: "ShannonEntropy#a177"
hash: "sema:ShannonEntropy#mh:SHA-256:a1774e05a3085b62748089790da6da7581e12e1144cab18adf622cb9059b1142"
type: "Primitives"
layer: "Infrastructure"
version: "1.0.0"
root: "8d7193fc97804cdc3aa9080728d8094732206c114f34d36b8ca2b89b943b3990"
license: null
url: "https://semahash.org/vocabularies/brainference/patterns/ShannonEntropy"
---

# ShannonEntropy

The average surprise of a distribution: how many bits it takes to predict an outcome

Infrastructure · Primitives

## Mechanism

For a discrete distribution P = {p_i} over states i, H(P) = -sum_i p_i log p_i, the expected self-information -log p_i of an outcome. Rare outcomes carry much information, likely ones little. H is maximal (log m for m states) when all states are equally likely and zero when all probability sits on one state. Applied to a system's possible configurations, high H means many weakly constrained configurations (variability, flexibility, exploration) and low H means strong constraints (regularity, coordination). Use log base 2 to measure in bits.

## Invariants

- H is non-negative and zero only for a distribution concentrated on one state
- H is maximal for the uniform distribution over the state space
- H depends only on the probabilities, not on what the states are or how they are ordered

## Preconditions

- A discrete state space has been defined and outcomes can be counted into it

## Failure modes

- State-space dependence: the same system yields different entropies under different state definitions or binnings, so values are comparable only within one state space
- Finite-sample bias: entropy estimated from few samples is biased low
- Reading low entropy as 'good order' without asking what constrains it

## Where this came from

- Thesis: do_2026_ant_collective_behavior (Ch. 1.3.1, Eqs. 1.3-1.5)

## Used by

- [DegreeEntropy](https://semahash.org/vocabularies/brainference/patterns/DegreeEntropy.md) (references)
- [JensenShannonDivergence](https://semahash.org/vocabularies/brainference/patterns/JensenShannonDivergence.md) (references)
- [SpectralEntropy](https://semahash.org/vocabularies/brainference/patterns/SpectralEntropy.md) (references)

## Identity

- Library: brainference 1.0.0 (root 8d7193fc9780)
- Ref: ShannonEntropy#a177
- Hash: sema:ShannonEntropy#mh:SHA-256:a1774e05a3085b62748089790da6da7581e12e1144cab18adf622cb9059b1142

## Links

- Page: https://semahash.org/vocabularies/brainference/patterns/ShannonEntropy
- JSON: https://semahash.org/vocabularies/brainference/patterns/ShannonEntropy.json
- Library: https://semahash.org/vocabularies/brainference
- Library index: https://semahash.org/vocabularies/brainference/index.json
