N_ha
  • Home
  • Posts

情報量・エントロピー・相互情報量・KLダイバージェンス

数学
機械学習

作成日 2025年7月18日金曜日

更新日 2025年7月18日金曜日

問題設定

A={0,1}A=\{0,1\}A={0,1} を標本空間とする確率変数 X,YX, YX,Y の同時確率 PXY(x,y)=PXY(X=x,Y=y)P_{XY}(x, y)=P_{XY}(X=x,Y=y)PXY​(x,y)=PXY​(X=x,Y=y) を以下のように定義し、周辺確率 PX(x),PY(y)P_X(x),P_Y(y)PX​(x),PY​(y) を求める。

周辺確率

PX(x)=∑y∈APXY(x,y)PY(y)=∑x∈APXY(x,y)\begin{aligned} P_X(x)&=\sum_{y\in A}P_{XY}(x, y)\\ P_Y(y)&=\sum_{x\in A}P_{XY}(x, y) \end{aligned}PX​(x)PY​(y)​=y∈A∑​PXY​(x,y)=x∈A∑​PXY​(x,y)​
YYY \ XXX000111PYP_YPY​
00018\frac{1}{8}81​14\frac{1}{4}41​38\frac{3}{8}83​
11138\frac{3}{8}83​14\frac{1}{4}41​58\frac{5}{8}85​
PXP_XPX​12\frac{1}{2}21​12\frac{1}{2}21​111

情報量

情報量 IXY(x,y),IX(x),IY(y)I_{XY}(x,y),I_X(x),I_Y(y)IXY​(x,y),IX​(x),IY​(y) を求める。

情報量

IXY(x,y)=−log⁡2PXY(x,y)IX(x)=−log⁡2PX(x)IY(y)=−log⁡2PY(y)\begin{aligned} I_{XY}(x,y)&=-\log_2 P_{XY}(x,y)\\ I_X(x)&=-\log_2 P_X(x)\\ I_Y(y)&=-\log_2 P_Y(y) \end{aligned}IXY​(x,y)IX​(x)IY​(y)​=−log2​PXY​(x,y)=−log2​PX​(x)=−log2​PY​(y)​
YYY \ XXX000111IYI_YIY​
0003332223−log⁡233-\log_2 33−log2​3
1113−log⁡233-\log_2 33−log2​32223−log⁡253-\log_2 53−log2​5
IXI_XIX​111111000

エントロピー

エントロピー HX(X),HY(Y)H_X(X),H_Y(Y)HX​(X),HY​(Y) を求める。

エントロピー

HX(X)=EX[IX(X)]=∑x∈APX(x)IX(x)=−∑x∈APX(x)log⁡2PX(x)HY(Y)=EY[IY(Y)]=∑y∈APY(y)IY(y)=−∑y∈APY(y)log⁡2PY(y)\begin{aligned} H_X(X)&=E_X[I_X(X)]=\sum_{x\in A} P_X(x)I_X(x)=-\sum_{x\in A} P_X(x)\log_2 P_X(x)\\ H_Y(Y)&=E_Y[I_Y(Y)]=\sum_{y\in A} P_Y(y)I_Y(y)=-\sum_{y\in A} P_Y(y)\log_2 P_Y(y) \end{aligned}HX​(X)HY​(Y)​=EX​[IX​(X)]=x∈A∑​PX​(x)IX​(x)=−x∈A∑​PX​(x)log2​PX​(x)=EY​[IY​(Y)]=y∈A∑​PY​(y)IY​(y)=−y∈A∑​PY​(y)log2​PY​(y)​

定理: エントロピーの上界式

HX(X)≤log⁡2∣A∣HY(Y)≤log⁡2∣A∣\begin{aligned} H_X(X)\leq \log_2 |A|\\ H_Y(Y)\leq \log_2 |A| \end{aligned}HX​(X)≤log2​∣A∣HY​(Y)≤log2​∣A∣​

HX(X)=log⁡2∣A∣H_X(X)=\log_2 |A|HX​(X)=log2​∣A∣ となるのは XXX が一様分布であるときである。

HX(X)=EX[IX(X)]=12⋅1+12⋅1=1HY(Y)=EY[IY(Y)]=38⋅(3−log⁡23)+58⋅(3−log⁡25)=3−38log⁡23−58log⁡25(=3−18log⁡233⋅55)\begin{aligned} H_X(X)&=E_X[I_X(X)]=\frac{1}{2}\cdot1+\frac{1}{2}\cdot1=1\\ H_Y(Y)&=E_Y[I_Y(Y)]=\frac{3}{8}\cdot(3-\log_2 3)+\frac{5}{8}\cdot(3-\log_2 5)=3-\frac{3}{8}\log_2 3-\frac{5}{8}\log_2 5(=3-\frac{1}{8}\log_2 3^3\cdot5^5) \end{aligned}HX​(X)HY​(Y)​=EX​[IX​(X)]=21​⋅1+21​⋅1=1=EY​[IY​(Y)]=83​⋅(3−log2​3)+85​⋅(3−log2​5)=3−83​log2​3−85​log2​5(=3−81​log2​33⋅55)​

条件付きエントロピー

条件付きエントロピー HY∣X(Y∣X),HX∣Y(X∣Y)H_{Y|X}(Y|X),H_{X|Y}(X|Y)HY∣X​(Y∣X),HX∣Y​(X∣Y) を求める。

条件付きエントロピー

HY∣X(Y∣X)=EXY[IY∣X(Y∣X)]=∑x∈A∑y∈APXY(x,y)IY∣X(Y∣X)=−∑x∈A∑y∈APXY(x,y)log⁡2PY∣X(Y∣X)HX∣Y(X∣Y)=EXY[IX∣Y(X∣Y)]=∑x∈A∑y∈APXY(x,y)IX∣Y(X∣Y)=−∑x∈A∑y∈APXY(x,y)log⁡2PX∣Y(X∣Y)\begin{aligned} H_{Y|X}(Y|X)&=E_{XY}[I_{Y|X}(Y|X)]=\sum_{x\in A}\sum_{y\in A} P_{XY}(x,y)I_{Y|X}(Y|X)=-\sum_{x\in A}\sum_{y\in A} P_{XY}(x,y)\log_2 P_{Y|X}(Y|X)\\ H_{X|Y}(X|Y)&=E_{XY}[I_{X|Y}(X|Y)]=\sum_{x\in A}\sum_{y\in A} P_{XY}(x,y)I_{X|Y}(X|Y)=-\sum_{x\in A}\sum_{y\in A} P_{XY}(x,y)\log_2 P_{X|Y}(X|Y) \end{aligned}HY∣X​(Y∣X)HX∣Y​(X∣Y)​=EXY​[IY∣X​(Y∣X)]=x∈A∑​y∈A∑​PXY​(x,y)IY∣X​(Y∣X)=−x∈A∑​y∈A∑​PXY​(x,y)log2​PY∣X​(Y∣X)=EXY​[IX∣Y​(X∣Y)]=x∈A∑​y∈A∑​PXY​(x,y)IX∣Y​(X∣Y)=−x∈A∑​y∈A∑​PXY​(x,y)log2​PX∣Y​(X∣Y)​

定理: エントロピーと条件付きエントロピーの関係

HX∣Y(X∣Y)≤HX(X)\begin{aligned} H_{X|Y}(X|Y)\leq H_X(X) \end{aligned}HX∣Y​(X∣Y)≤HX​(X)​

HX∣Y(X∣Y)=HX(X)H_{X|Y}(X|Y)=H_X(X)HX∣Y​(X∣Y)=HX​(X) となるのは XXX と YYY が独立なときである。

HY∣X(Y∣X)=EXY[IY∣X(Y∣X)]=18⋅2+38⋅(2−log⁡23)+14⋅1+14⋅1=32−38log⁡23HX∣Y(X∣Y)=EXY[IX∣Y(X∣Y)]=18⋅log⁡23+38⋅(log⁡25−log⁡23)+14⋅(log⁡23−1)+14⋅(log⁡25−1)=−12+58log⁡25\begin{aligned} H_{Y|X}(Y|X)&=E_{XY}[I_{Y|X}(Y|X)]=\frac{1}{8}\cdot2+\frac{3}{8}\cdot(2-\log_2 3)+\frac{1}{4}\cdot1+\frac{1}{4}\cdot1=\frac{3}{2}-\frac{3}{8}\log_2 3\\ H_{X|Y}(X|Y)&=E_{XY}[I_{X|Y}(X|Y)]=\frac{1}{8}\cdot\log_2 3+\frac{3}{8}\cdot(\log_2 5-\log_2 3)+\frac{1}{4}\cdot(\log_2 3-1)+\frac{1}{4}\cdot(\log_2 5-1)=-\frac{1}{2}+\frac{5}{8}\log_2 5 \end{aligned}HY∣X​(Y∣X)HX∣Y​(X∣Y)​=EXY​[IY∣X​(Y∣X)]=81​⋅2+83​⋅(2−log2​3)+41​⋅1+41​⋅1=23​−83​log2​3=EXY​[IX∣Y​(X∣Y)]=81​⋅log2​3+83​⋅(log2​5−log2​3)+41​⋅(log2​3−1)+41​⋅(log2​5−1)=−21​+85​log2​5​

同時エントロピー

同時エントロピー HXY(X,Y)H_{XY}(X,Y)HXY​(X,Y) を求める。

同時エントロピー

HXY(X,Y)=EXY[IXY(X,Y)]=∑x∈A∑y∈APXY(x,y)IXY(x,y)=−∑x∈A∑y∈APXY(x,y)log⁡2PXY(x,y)\begin{aligned} H_{XY}(X,Y)&=E_{XY}[I_{XY}(X,Y)]=\sum_{x\in A}\sum_{y\in A} P_{XY}(x,y)I_{XY}(x,y)=-\sum_{x\in A}\sum_{y\in A} P_{XY}(x,y)\log_2 P_{XY}(x,y) \end{aligned}HXY​(X,Y)​=EXY​[IXY​(X,Y)]=x∈A∑​y∈A∑​PXY​(x,y)IXY​(x,y)=−x∈A∑​y∈A∑​PXY​(x,y)log2​PXY​(x,y)​

定理: エントロピーの加法性

HXY(X,Y)=HX(X)+HY∣X(Y∣X)=HY(Y)+HX∣Y(X∣Y)\begin{aligned} H_{XY}(X,Y)&=H_X(X)+H_{Y|X}(Y|X)=H_Y(Y)+H_{X|Y}(X|Y) \end{aligned}HXY​(X,Y)​=HX​(X)+HY∣X​(Y∣X)=HY​(Y)+HX∣Y​(X∣Y)​
HXY(X,Y)=EXY[IXY(X,Y)]=18⋅3+38⋅(3−log⁡23)+14⋅2+14⋅2=52−38log⁡23\begin{aligned} H_{XY}(X,Y)&=E_{XY}[I_{XY}(X,Y)]=\frac{1}{8}\cdot3+\frac{3}{8}\cdot(3-\log_2 3)+\frac{1}{4}\cdot2+\frac{1}{4}\cdot2=\frac{5}{2}-\frac{3}{8}\log_2 3 \end{aligned}HXY​(X,Y)​=EXY​[IXY​(X,Y)]=81​⋅3+83​⋅(3−log2​3)+41​⋅2+41​⋅2=25​−83​log2​3​

相互情報量

相互情報量 I(X;Y)I(X;Y)I(X;Y) を求める。

相互情報量

I(X;Y)=EXY[IX(X)+IY(Y)−IXY(X,Y)]=∑x∈A∑y∈APXY(x,y)(IX(x)+IY(y)−IXY(x,y))=∑x∈A∑y∈APXY(x,y)log⁡2PXY(x,y)PX(x)PY(y)\begin{aligned} I(X;Y)&=E_{XY}[I_X(X)+I_Y(Y)-I_{XY}(X,Y)]=\sum_{x\in A}\sum_{y\in A} P_{XY}(x,y)(I_X(x)+I_Y(y)-I_{XY}(x,y))=\sum_{x\in A}\sum_{y\in A} P_{XY}(x,y)\log_2 \frac{P_{XY}(x,y)}{P_X(x)P_Y(y)} \end{aligned}I(X;Y)​=EXY​[IX​(X)+IY​(Y)−IXY​(X,Y)]=x∈A∑​y∈A∑​PXY​(x,y)(IX​(x)+IY​(y)−IXY​(x,y))=x∈A∑​y∈A∑​PXY​(x,y)log2​PX​(x)PY​(y)PXY​(x,y)​​

定理

I(X;Y)=D(PXY∣∣PXPY)\begin{aligned} I(X;Y)&=D(P_{XY}||P_XP_Y) \end{aligned}I(X;Y)​=D(PXY​∣∣PX​PY​)​

定理: 相互情報量とエントロピーの関係

I(X;Y)=H(X)+H(Y)−H(X,Y)I(X;Y)=H(X)−H(X∣Y)=H(Y)−H(Y∣X)I(X;Y)=I(Y;X)I(X;X)=HX(X)\begin{aligned} I(X;Y)&=H(X)+H(Y)-H(X,Y)\\ I(X;Y)&=H(X)-H(X|Y)=H(Y)-H(Y|X)\\ I(X;Y)&=I(Y;X)\\ I(X;X)&=H_X(X) \end{aligned}I(X;Y)I(X;Y)I(X;Y)I(X;X)​=H(X)+H(Y)−H(X,Y)=H(X)−H(X∣Y)=H(Y)−H(Y∣X)=I(Y;X)=HX​(X)​

定理: 相互情報量の非負性

I(X;Y)≥0\begin{aligned} I(X;Y)\geq0 \end{aligned}I(X;Y)≥0​

I(X;Y)=0I(X;Y)=0I(X;Y)=0 となるのは XXX と YYY が独立なときである。

I(X;Y)=18⋅(1−log⁡23)+38(1+log⁡23−log⁡25)+14(2−log⁡23)+14(2−log⁡25)=32−58log⁡25\begin{aligned} I(X;Y)&=\frac{1}{8}\cdot(1-\log_2 3)+\frac{3}{8}(1+\log_2 3-\log_2 5)+\frac{1}{4}(2-\log_2 3)+\frac{1}{4}(2-\log_2 5)=\frac{3}{2}-\frac{5}{8}\log_2 5 \end{aligned}I(X;Y)​=81​⋅(1−log2​3)+83​(1+log2​3−log2​5)+41​(2−log2​3)+41​(2−log2​5)=23​−85​log2​5​

交差エントロピー

交差エントロピー H(PX,PY),H(PY,PX)H(P_X,P_Y),H(P_Y,P_X)H(PX​,PY​),H(PY​,PX​) を求める。

交差エントロピー

H(PX,PY)=EX[IY(X)]=∑x∈APX(x)IY(x)=−∑x∈APX(x)log⁡2PY(x)H(PY,PX)=EY[IX(Y)]=∑y∈APY(y)IX(y)=−∑y∈APY(y)log⁡2PX(y)\begin{aligned} H(P_X,P_Y)&=E_X[I_Y(X)]=\sum_{x\in A}P_X(x)I_Y(x)=-\sum_{x\in A}P_X(x)\log_2 P_Y(x)\\ H(P_Y,P_X)&=E_Y[I_X(Y)]=\sum_{y\in A}P_Y(y)I_X(y)=-\sum_{y\in A}P_Y(y)\log_2 P_X(y) \end{aligned}H(PX​,PY​)H(PY​,PX​)​=EX​[IY​(X)]=x∈A∑​PX​(x)IY​(x)=−x∈A∑​PX​(x)log2​PY​(x)=EY​[IX​(Y)]=y∈A∑​PY​(y)IX​(y)=−y∈A∑​PY​(y)log2​PX​(y)​
H(PX,PY)=12⋅(3−log⁡23)+12⋅(3−log⁡25)=3−12log⁡23−12log⁡25(=3−12log⁡23⋅5)H(PY,PX)=38⋅1+58⋅1=1\begin{aligned} H(P_X,P_Y)&=\frac{1}{2}\cdot(3-\log_2 3)+\frac{1}{2}\cdot(3-\log_2 5)=3-\frac{1}{2}\log_2 3-\frac{1}{2}\log_2 5(=3-\frac{1}{2}\log_2 3\cdot5)\\ H(P_Y,P_X)&=\frac{3}{8}\cdot1+\frac{5}{8}\cdot1=1 \end{aligned}H(PX​,PY​)H(PY​,PX​)​=21​⋅(3−log2​3)+21​⋅(3−log2​5)=3−21​log2​3−21​log2​5(=3−21​log2​3⋅5)=83​⋅1+85​⋅1=1​

KL ダイバージェンス

KL ダイバージェンス D(PX∣∣PY),D(PY∣∣PX)D(P_X||P_Y),D(P_Y||P_X)D(PX​∣∣PY​),D(PY​∣∣PX​) を求める。

KL ダイバージェンス

D(PX∣∣PY)=EX[IY(X)−IX(X)]=∑x∈APX(x)(IY(x)−IX(x))=∑x∈APX(x)log⁡2PX(x)PY(x)D(PY∣∣PX)=EY[IX(Y)−IY(Y)]=∑y∈APY(y)(IX(y)−IY(y))=∑y∈APY(y)log⁡2PY(y)PX(y)\begin{aligned} D(P_X||P_Y)&=E_X[I_Y(X)-I_X(X)]=\sum_{x\in A}P_X(x)(I_Y(x)-I_X(x))=\sum_{x\in A}P_X(x)\log_2 \frac{P_X(x)}{P_Y(x)}\\ D(P_Y||P_X)&=E_Y[I_X(Y)-I_Y(Y)]=\sum_{y\in A}P_Y(y)(I_X(y)-I_Y(y))=\sum_{y\in A}P_Y(y)\log_2 \frac{P_Y(y)}{P_X(y)} \end{aligned}D(PX​∣∣PY​)D(PY​∣∣PX​)​=EX​[IY​(X)−IX​(X)]=x∈A∑​PX​(x)(IY​(x)−IX​(x))=x∈A∑​PX​(x)log2​PY​(x)PX​(x)​=EY​[IX​(Y)−IY​(Y)]=y∈A∑​PY​(y)(IX​(y)−IY​(y))=y∈A∑​PY​(y)log2​PX​(y)PY​(y)​​

定理

D(PX∣∣PY)=H(PX,PY)−HX(X)D(PY∣∣PX)=H(PY,PX)−HY(Y)\begin{aligned} D(P_X||P_Y)&=H(P_X,P_Y)-H_X(X)\\ D(P_Y||P_X)&=H(P_Y,P_X)-H_Y(Y) \end{aligned}D(PX​∣∣PY​)D(PY​∣∣PX​)​=H(PX​,PY​)−HX​(X)=H(PY​,PX​)−HY​(Y)​

定理: ダイバージェンスの非負性

D(PX∣∣PY)≥0D(PY∣∣PX)≥0\begin{aligned} D(P_X||P_Y)\geq0\\ D(P_Y||P_X)\geq0 \end{aligned}D(PX​∣∣PY​)≥0D(PY​∣∣PX​)≥0​

D(PX∣∣PY)=D(PY∣∣PX)=0D(P_X||P_Y)=D(P_Y||P_X)=0D(PX​∣∣PY​)=D(PY​∣∣PX​)=0 となるのは ∀x∈A,PX(x)=PY(x)\forall x\in A,P_X(x)=P_Y(x)∀x∈A,PX​(x)=PY​(x) のときである。

D(PX∣∣PY)=12⋅(2−log23)+12(2−log⁡25)=2−12log⁡23−12log⁡25(=2−12log⁡23⋅5)D(PY∣∣PX)=38⋅(−2+log⁡23)+58⋅(−2+log⁡25)=−2+38log⁡23+58log⁡25(=−2+18log⁡233⋅55)\begin{aligned} D(P_X||P_Y)&=\frac{1}{2}\cdot(2-log_2 3)+\frac{1}{2}(2-\log_2 5)=2-\frac{1}{2}\log_2 3-\frac{1}{2}\log_2 5(=2-\frac{1}{2}\log_2 3\cdot5)\\ D(P_Y||P_X)&=\frac{3}{8}\cdot(-2+\log_2 3)+\frac{5}{8}\cdot(-2+\log_2 5)=-2+\frac{3}{8}\log_2 3+\frac{5}{8}\log_2 5(=-2+\frac{1}{8}\log_2 3^3\cdot5^5) \end{aligned}D(PX​∣∣PY​)D(PY​∣∣PX​)​=21​⋅(2−log2​3)+21​(2−log2​5)=2−21​log2​3−21​log2​5(=2−21​log2​3⋅5)=83​⋅(−2+log2​3)+85​⋅(−2+log2​5)=−2+83​log2​3+85​log2​5(=−2+81​log2​33⋅55)​