欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > 积跬步至千里 || 信息熵与KL散度

积跬步至千里 || 信息熵与KL散度

2025/2/5 0:47:57 来源:https://blog.csdn.net/weixin_40234309/article/details/139925612  浏览:    关键词:积跬步至千里 || 信息熵与KL散度

信息熵与KL散度

在1948年,香农(Shannon)在他著名的《通信的数学原理》论文中指出:“信息是用来消除随机不确定性的东西”,并提出了“信息熵”的概念(借用了热力学中熵的概念),来解决信息的度量问题。也就是量化信息(信息,泛指人类社会传播的一切内容,指音讯、消息、通信系统传输和处理的对象。)。
一个事件或一个系统,准确的说是一个随机变量,它有着一定的不确定性。要消除这个不确定性,就需要引入很多的信息,这些很多信息的度量就用“信息熵”表达。需要引入消除不确定性的信息量越多,则信息熵越高,反之则越低。

根据香农(Shannon)给出的信息熵公式,对于任意一个随机变量X,它的信息熵定义如下,单位为比特(bit):

H [ X ] = E x ∼ p ( x ) [ − log ⁡ p ( x ) ] = − ∫ x ∈ X p ( x ) log ⁡ p ( x ) d x = − ∑ x ∈ X p ( x ) log ⁡ p ( x ) H[\mathbf X]=\mathbb{E}_{\mathbf x\sim p(\mathbf x)}[-\log p(\mathbf x)]=-\int_{\mathbf x\in\mathbf X}p(\mathbf x)\log p(\mathbf x)d\mathbf x=-\sum_{\mathbf x\in\mathbf X}p(\mathbf x)\log p(\mathbf x) H[X]=Exp(x)[logp(x)]=xXp(x)logp(x)dx=xXp(x)logp(x)

条件熵

H [ Y ∣ X ] = ∑ x ∈ X E x ∼ p ( x ) [ H ( Y ∣ X = x ) ] = − ∑ x ∈ X p ( x ) ∑ y ∈ Y [ p ( y ∣ x ) log ⁡ p ( y ∣ x ) ] = − ∑ x ∈ X ∑ y ∈ Y [ p ( x , y ) log ⁡ p ( y ∣ x ) ] \begin{align} H[\mathbf Y|\mathbf X]&=\sum_{\mathbf x \in \mathbf X}\mathbb{E}_{\mathbf x\sim p(\mathbf x)}[H(\mathbf Y|\mathbf X = \mathbf x)]\notag\\ &=-\sum_{\mathbf x \in \mathbf X}p(\mathbf x)\sum_{\mathbf y \in \mathbf Y}[p(\mathbf y|\mathbf x)\log p(\mathbf y|\mathbf x)]\notag\\ &=-\sum_{\mathbf x \in \mathbf X}\sum_{\mathbf y \in \mathbf Y}[p(\mathbf x, \mathbf y)\log p(\mathbf y|\mathbf x)]\notag \end{align} H[YX]=xXExp(x)[H(YX=x)]=xXp(x)yY[p(yx)logp(yx)]=xXyY[p(x,y)logp(yx)]

KL 散度 Kullback-Leibler Divergence(相对熵)

KL散度用来衡量两个分布对于同一变量的差异情况。在概率学中,我们经常使用更简单的分布来近似观察数据或复杂分布。KL散度能帮助我们度量使用一种分布近似另一种分布时所损失的信息量。设p为观察得到的概率分布,q为另一分布来近似p,则p、q的K-L散度为:

D K L ( p ∥ q ) = E x ∼ p ( x ) [ log ⁡ p ( x ) − log ⁡ q ( x ) ] = ∫ p ( x ) ( log ⁡ p ( x ) − log ⁡ q ( x ) ) d x D_{KL}(p\|q)=\mathbb{E}_{\mathbf x\sim p(\mathbf x)}\Big[\log p(\mathbf x)-\log q(\mathbf x)\Big]=\int p(\mathbf x)\Big(\log p(\mathbf x)-\log q(\mathbf x) \Big)d\mathbf x DKL(pq)=Exp(x)[logp(x)logq(x)]=p(x)(logp(x)logq(x))dx

D K L ( p ∥ q ) = ∑ i p ( x i ) ( log ⁡ p ( x i ) − log ⁡ q ( x i ) ) D_{KL}(p\|q)=\sum_ip(\mathbf x_i)\Big(\log p(\mathbf x_i)-\log q(\mathbf x_i) \Big) DKL(pq)=ip(xi)(logp(xi)logq(xi))

显然,根据上述公式,K-L散度其实是统一随机变量x的原始分布p和近似分布q之间的对数差值的期望。如果继续用2为底的对数计算,则K-L散度值表示信息损失的二进制位数。K-L散度通常也被写为以下形式:

D K L ( p ∥ q ) = ∑ i p ( x i ) ⋅ log ⁡ p ( x i ) q ( x i ) D_{KL}(p\|q)=\sum_ip(\mathbf x_i)\cdot\log \frac{p(\mathbf x_i)}{q(\mathbf x_i)} DKL(pq)=ip(xi)logq(xi)p(xi)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com