Differential entropy H[p] measures the average surprise of samples
drawn from p, in nats. Unlike discrete entropy it is not bounded
below by zero — a tightly concentrated continuous density has negative
differential entropy. The codebase reports entropy as one of the
quick-look statistics on every grid posterior.
For a continuous density on the real line::
H[p] = − ∫ p(x) log p(x) dx
The integrand is taken to be zero wherever p(x) = 0.
Univariate::
H[N(μ, σ²)] = ½ log(2π e σ²)
Multivariate (dimension d)::
H[N(μ, Σ)] = ½ log( (2π e)^d |Σ| )
| Function | Signature | Notes |
|---|---|---|
grid_entropy |
(p, x_grid) -> float |
Trapezoid rule. |
gaussian_entropy_univariate |
(sigma2) -> float |
Closed form. |
gaussian_entropy_mvn |
(cov) -> float |
Cholesky-based log-det; never inverts. |
InferenceResult.entropy |
() -> float |
Convenience on a grid posterior. |
All live in active_inference.core.diagnostics.
tests/core/test_diagnostics.py::TestEntropy covers:
grid_entropy on a dense grid.ValueError.σ² < 1 / (2π e) has H[p] < 0. This is expected, not a bug.x_grid rather than narrowing the grid spacing.1/log(2) for
bits.divergences.md — KL is the “extra” entropy paid
for using q instead of p.../topics/bayesian_inference.md
— entropy as a uncertainty diagnostic on the posterior.../reference/core.md — full API.