香农与信息的比特
1948 年,香农以《通信的数学理论》开创了信息论。本演示绘制二元熵 H(p),标记当前概率,并把 log2(N) 与识别 N 个等概率结果所需的“是/否”问题数量联系起来。
H(p) = −p·log2(p) − (1−p)·log2(1−p) = 1.0000 bits · outcomes H = log2(8) = 3 bits
8 equally likely outcomes need 3 bits, i.e. 3 yes/no questions at most. Entropy is the minimum average number of questions.
Each yes/no question has at most 2 answers, so 20 questions distinguish at most 2^20 ≈ 1,048,576 items. One million equally likely items carry log2(1,000,000) ≈ 19.93 bits, so 20 questions are enough.
A fair coin (p = 0.5) carries one full bit of uncertainty. Push p toward 0 or 1 and the outcome becomes predictable, so H(p) drops toward zero. The outcome buttons show the same idea for many equally likely results: N outcomes carry log2(N) bits, the number of yes/no questions needed to identify one.
你看到的是什么
二元熵 H(p) = −p·log2(p) − (1−p)·log2(1−p) 度量正面概率为 p 的硬币的平均不确定性。
若有 N 个等概率结果,熵为 log2(N) 比特,等于平均而言找出答案所需的最少“是/否”问题数。
比特就是单位:一次公平抛硬币的熵恰好为 1。可预测的结果熵接近于 0。
为什么重要
香农的框架支撑着压缩、纠错、密码学和机器学习。它既解释了数据压缩的极限,也说明了为什么 20 个“是/否”问题就能从一百万个选项中找出一个。
复杂度与细节
计算 H(p) 为 O(1)。对 N 个结果计算 log2(N) 也是 O(1);构建完整决策树则需要 O(N)。
常见问题
为什么 p 为 0 或 1 时熵为零?+
如果结果已确定,观察它不会带来新信息。没有不确定性需要消除,因此获得的信息为零比特。
为什么一百万个选项只需 20 个问题?+
每个“是/否”问题最多把可区分的情况翻倍。k 个问题最多区分 2^k 个选项,而 2^20 略大于一百万。