信息论基础

本文深入探讨信息量、信息熵、交叉熵及KL散度的概念,解释它们在信息理论中的作用,以及如何度量不确定性和信息的多少。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

引言

所谓的信息,就是以前不知道现在知道的事实,如果某件事以前就知道,当别人再告诉你时,你会忽略,这件事对你的认知没有任何影响,这就不叫信息,反之,如果某件事以前你不知道,有人告诉你了,你现在知道了,那么对你而言,这件事就是信息。

让我们更进一步,看一件事带来的信息量的大小如何来度量。顾名思义,信息量就是度量信息大小的一种量,让我们看一个形象的例子。有人告诉你巴西赢了世界杯,那么这件事对大多数人而言,并不值得关注,它并没有带来多少惊喜,如果是中国赢得了世界杯,那么这件事可能会刷新很多人的世界观,这件事带来的信息量就特别大,我们常说的黑天鹅事件就是概率极低但确实发生了的事件。定性的说,小概率事件带来的信息量大,大概率事件带来的信息量小。下面我们看下以上这句话如何定量的描述。

用概率来度量信息是合理的,这并不是空穴来风,半个多世纪之前,香农提出的信息论便是以概率论为基础。执果索因,我们先来看看香农为什么用事件发生概率的对数来度量信息量。

用概率描述信息量的重要性质:

  • 事件发生的概率越低,信息量越大
  • 事件发生的概率越高,信息量越少
  • 多个事件同时发生的概率是多个事件概率相乘,总信息量是多个事件信息量相加

通过第三点,我们可以知道:
x 1 和 x 2 同 时 发 生 的 概 率 : P ( x 1 , x 2 ) = P ( x 1 ) ⋅ P ( x 2 ) x_1和x_2同时发生的概率:P(x_1, x_2) = P(x_1)\cdot P(x_2) x1x2P(x1,x2)=P(x1)P(x2) x 1 和 x 2 总 信 息 量 : l o g [ P ( x 1 ) P ( x 2 ) ] = l o g [ P ( x 1 ) ] + l o g [ P ( x 2 ) ] x_1和x_2总信息量:log[P(x_1)P(x_2)] = log[P(x_1)] + log[P(x_2)] x1x2log[P(x1)P(x2)]=log[P(x1)]+log[P(x2)]
通过前两点,我们知道信息量,信息量和概率之间一定是减函数的关系。
由此确定,信息量描述为:
I ( x ) = − l o g P ( x ) I(x) = -logP(x) I(x)=logP(x)
I ( x ) I(x) I(x)为自信息,如果以 2 为底,单位是bit。当使用以 e 为底的对数时,单位将是 nat。对于基底为 10 的对数,单位是 hart。

信息熵

对于离散系统
H ( X ) = − ∑ i p i l o g ( p i ) H(X) = -\sum_{i}p_ilog (p_{i}) H(X)=ipilog(pi)
对于连续的系统
H ( x ) = E x ∼ P [ I ( x ) ] = − E x ∼ P [ l o g P ( x ) ] H(x) = E_{x\sim P}[I(x)] = - E_{x\sim P}[log P(x)] H(x)=ExP[I(x)]=ExP[logP(x)]
信息熵反应了信息量的多少,信息熵越大表明信息越多,随机事件的信息量与随机变量的确定性有关,不确定性越大包含的信息量就越大,所有可能的事件等概率时不确定性最高。

交叉熵

令不完美的编码用 Q Q Q表示,平均编码长度为
H ( P , Q ) = − E P ( x ) Q ( x ) = − ∫ P ( x ) l o g Q ( x ) d x H(P,Q) = -E_{P(x)}Q(x) = -\int P(x)logQ(x)dx H(P,Q)=EP(x)Q(x)=P(x)logQ(x)dx

交叉熵用来衡量编码方案不一定完美时,平均编码的长度。
交叉熵常用作损失函数。原因是真实的样本分布是 P P P, 而模型概率分布是 Q Q Q, 只有模型分布于真实样本分布相等时,交叉熵最小。

KL散度

D K L ( P ∣ ∣ Q ) = E x ∼ P [ l o g P ( x ) Q ( x ) ] = ∫ P ( x ) l o g P ( x ) d x − ∫ P ( x ) l o g Q ( x ) d x D_{KL}(P||Q) = E_{x\sim P}[log \frac{P(x)}{Q(x)}] = \int P(x)logP(x)dx -\int P(x)logQ(x)dx DKL(PQ)=ExP[logQ(x)P(x)]=P(x)logP(x)dxP(x)logQ(x)dx
KL散度用来衡量两个概率分布之间的相似程度,其重要性质是非负性,而且,当且仅当两个概率分布处处相等时,KL散度取到零。KL散度与一般的距离不同,它一般不具有对称性。
H ( P , Q ) = D K L ( P ∣ ∣ Q ) + H ( P ) H(P, Q) = D_{KL}(P||Q) + H(P) H(P,Q)=DKL(PQ)+H(P)上述关系很容易推导,此处从略,可以看出样本的真实分布 P P P保持不变,最优化交叉熵等价于最优化KL散度。KL散度还可用于异常检测

Reference:
https://www.cnblogs.com/yinheyi/p/6426431.html
https://blog.youkuaiyun.com/dog250/article/details/78944526

CONTENTS Contents v Preface to the Second Edition xv Preface to the First Edition xvii Acknowledgments for the Second Edition xxi Acknowledgments for the First Edition xxiii 1 Introduction and Preview 1.1 Preview of the Book 2 Entropy, Relative Entropy, and Mutual Information 2.1 Entropy 2.2 Joint Entropy and Conditional Entropy 2.3 Relative Entropy and Mutual Information 2.4 Relationship Between Entropy and Mutual Information 2.5 Chain Rules for Entropy, Relative Entropy,and Mutual Information 2.6 Jensen’s Inequality and Its Consequences 2.7 Log Sum Inequality and Its Applications 2.8 Data-Processing Inequality 2.9 Sufficient Statistics 2.10 Fano’s Inequality Summary Problems Historical Notes v vi CONTENTS 3 Asymptotic Equipartition Property 3.1 Asymptotic Equipartition Property Theorem 3.2 Consequences of the AEP: Data Compression 3.3 High-Probability Sets and the Typical Set Summary Problems Historical Notes 4 Entropy Rates of a Stochastic Process 4.1 Markov Chains 4.2 Entropy Rate 4.3 Example: Entropy Rate of a Random Walk on a Weighted Graph 4.4 Second Law of Thermodynamics 4.5 Functions of Markov Chains Summary Problems Historical Notes 5 Data Compression 5.1 Examples of Codes 5.2 Kraft Inequality 5.3 Optimal Codes 5.4 Bounds on the Optimal Code Length 5.5 Kraft Inequality for Uniquely Decodable Codes 5.6 Huffman Codes 5.7 Some Comments on Huffman Codes 5.8 Optimality of Huffman Codes 5.9 Shannon–Fano–Elias Coding 5.10 Competitive Optimality of the Shannon Code 5.11 Generation of Discrete Distributions from Fair Coins Summary Problems Historical Notes CONTENTS vii 6 Gambling and Data Compression 6.1 The Horse Race 159 6.2 Gambling and Side Information 164 6.3 Dependent Horse Races and Entropy Rate 166 6.4 The Entropy of English 168 6.5 Data Compression and Gambling 171 6.6 Gambling Estimate of the Entropy of English 173 Summary 175 Problems 176 Historical Notes 182 7 Channel Capacity 183 7.1 Examples of Channel Capacity 1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值