情報量・エントロピー・相互情報量・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)=∑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}
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)=−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}
YY \ XX0011IYI_Y
0033223−log⁡233-\log_2 3
113−log⁡233-\log_2 3223−log⁡253-\log_2 5
IXI_X111100

エントロピー

エントロピー HX(X),HY(Y)H_X(X),H_Y(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)≤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)=log⁡2∣A∣H_X(X)=\log_2 |A| となるのは XX が一様分布であるときである。

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}

条件付きエントロピー

条件付きエントロピー HY∣X(Y∣X),HX∣Y(X∣Y)H_{Y|X}(Y|X),H_{X|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}

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

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)H_{X|Y}(X|Y)=H_X(X) となるのは XX と YY が独立なときである。

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}

同時エントロピー

同時エントロピー HXY(X,Y)H_{XY}(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)=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)=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}

相互情報量

相互情報量 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)=D(PXY∣∣PXPY)\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(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)≥0\begin{aligned} I(X;Y)\geq0 \end{aligned}

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

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}

交差エントロピー

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

交差エントロピー

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)=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}

KL ダイバージェンス

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

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)=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)≥0D(PY∣∣PX)≥0\begin{aligned} D(P_X||P_Y)\geq0\\ D(P_Y||P_X)\geq0 \end{aligned}

D(PX∣∣PY)=D(PY∣∣PX)=0D(P_X||P_Y)=D(P_Y||P_X)=0 となるのは ∀x∈A,PX(x)=PY(x)\forall x\in A,P_X(x)=P_Y(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}