Skip to content

香农信息论 — 练习 ​

Download exercise.py

实现 binary_entropy(p):−plog2⁡p−(1−p)log2⁡(1−p),对 p∈(0,1)。公平比特 p=0.5 应得到 1 bit(与 demo 的 h2 相同,不必做 clip)。

bash
cd docs/information/shannon/code
python exercise.py

源码位置 ​

clone 后打开(相对仓库根目录):

docs/information/shannon/code/exercise.py