def
definition
def or abbrev
sourceEntropy
show as:
view Lean formalization →
formal statement (Lean)
65noncomputable def sourceEntropy (probs : List ℝ) : ℝ :=
proof body
Definition body.
66 -probs.foldl (fun acc p => acc + p * log2 p) 0
67
68/-! ## Compression Examples -/
69
70/-- Example: Fair coin (entropy = 1 bit).
71
72 P(H) = 0.5, P(T) = 0.5
73 H = -0.5 log₂(0.5) - 0.5 log₂(0.5) = 0.5 + 0.5 = 1 bit
74
75 Can't compress below 1 bit per symbol! -/