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

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

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

問題設定

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

周辺確率

PX(x)=yAPXY(x,y)PY(y)=xAPXY(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}
YY \ XX0011PYP_Y
0018\frac{1}{8}14\frac{1}{4}38\frac{3}{8}
1138\frac{3}{8}14\frac{1}{4}58\frac{5}{8}
PXP_X12\frac{1}{2}12\frac{1}{2}11

情報量

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

情報量

IXY(x,y)=log2PXY(x,y)IX(x)=log2PX(x)IY(y)=log2PY(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}
YY \ XX0011IYI_Y
0033223log233-\log_2 3
113log233-\log_2 3223log253-\log_2 5
IXI_X111100

エントロピー

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

エントロピー

HX(X)=EX[IX(X)]=xAPX(x)IX(x)=xAPX(x)log2PX(x)HY(Y)=EY[IY(Y)]=yAPY(y)IY(y)=yAPY(y)log2PY(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)log2AHY(Y)log2A\begin{aligned} H_X(X)\leq \log_2 |A|\\ H_Y(Y)\leq \log_2 |A| \end{aligned}

HX(X)=log2AH_X(X)=\log_2 |A| となるのは XX が一様分布であるときである。

HX(X)=EX[IX(X)]=121+121=1HY(Y)=EY[IY(Y)]=38(3log23)+58(3log25)=338log2358log25(=318log23355)\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}

条件付きエントロピー

条件付きエントロピー HYX(YX),HXY(XY)H_{Y|X}(Y|X),H_{X|Y}(X|Y) を求める。

条件付きエントロピー

HYX(YX)=EXY[IYX(YX)]=xAyAPXY(x,y)IYX(YX)=xAyAPXY(x,y)log2PYX(YX)HXY(XY)=EXY[IXY(XY)]=xAyAPXY(x,y)IXY(XY)=xAyAPXY(x,y)log2PXY(XY)\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}

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

HXY(XY)HX(X)\begin{aligned} H_{X|Y}(X|Y)\leq H_X(X) \end{aligned}

HXY(XY)=HX(X)H_{X|Y}(X|Y)=H_X(X) となるのは XXYY が独立なときである。

HYX(YX)=EXY[IYX(YX)]=182+38(2log23)+141+141=3238log23HXY(XY)=EXY[IXY(XY)]=18log23+38(log25log23)+14(log231)+14(log251)=12+58log25\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}

同時エントロピー

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

同時エントロピー

HXY(X,Y)=EXY[IXY(X,Y)]=xAyAPXY(x,y)IXY(x,y)=xAyAPXY(x,y)log2PXY(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)=HX(X)+HYX(YX)=HY(Y)+HXY(XY)\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)=EXY[IXY(X,Y)]=183+38(3log23)+142+142=5238log23\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}

相互情報量

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

相互情報量

I(X;Y)=EXY[IX(X)+IY(Y)IXY(X,Y)]=xAyAPXY(x,y)(IX(x)+IY(y)IXY(x,y))=xAyAPXY(x,y)log2PXY(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)=D(PXYPXPY)\begin{aligned} I(X;Y)&=D(P_{XY}||P_XP_Y) \end{aligned}

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

I(X;Y)=H(X)+H(Y)H(X,Y)I(X;Y)=H(X)H(XY)=H(Y)H(YX)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)0\begin{aligned} I(X;Y)\geq0 \end{aligned}

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

I(X;Y)=18(1log23)+38(1+log23log25)+14(2log23)+14(2log25)=3258log25\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}

交差エントロピー

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

交差エントロピー

H(PX,PY)=EX[IY(X)]=xAPX(x)IY(x)=xAPX(x)log2PY(x)H(PY,PX)=EY[IX(Y)]=yAPY(y)IX(y)=yAPY(y)log2PX(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)=12(3log23)+12(3log25)=312log2312log25(=312log235)H(PY,PX)=381+581=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}

KL ダイバージェンス

KL ダイバージェンス D(PXPY),D(PYPX)D(P_X||P_Y),D(P_Y||P_X) を求める。

KL ダイバージェンス

D(PXPY)=EX[IY(X)IX(X)]=xAPX(x)(IY(x)IX(x))=xAPX(x)log2PX(x)PY(x)D(PYPX)=EY[IX(Y)IY(Y)]=yAPY(y)(IX(y)IY(y))=yAPY(y)log2PY(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(PXPY)=H(PX,PY)HX(X)D(PYPX)=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(PXPY)0D(PYPX)0\begin{aligned} D(P_X||P_Y)\geq0\\ D(P_Y||P_X)\geq0 \end{aligned}

D(PXPY)=D(PYPX)=0D(P_X||P_Y)=D(P_Y||P_X)=0 となるのは xA,PX(x)=PY(x)\forall x\in A,P_X(x)=P_Y(x) のときである。

D(PXPY)=12(2log23)+12(2log25)=212log2312log25(=212log235)D(PYPX)=38(2+log23)+58(2+log25)=2+38log23+58log25(=2+18log23355)\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}