メッセージを受信した後、あなたはどのような可能性を除外しましたか?まだどれくらい分からない状態でしょうか?情報理論は、この変化を計算可能な量に変換します。 それは与えられた確率モデルにおける不確実性を計測するものであり、文の意味、真偽、または価値を直接測定するものではありません。
この章では、まず三つの事柄を見ていきます:候補がどのように回答によって除外されるか、単発の情報がどのように平均値へと集約されるか、そして一つの変数がどのようにして別の変数についての理解を助けるかです。全体を通して対数の底は 2 を用い、単位は bit とします。特に断りのない限り、有限離散確率変数について議論します。
8つの候補から1つの答えへ
確率変数 X が 1 から 8 まで一様に確率で取るとします。一度に問えるのは真偽問題のみで、最終的には答えを特定する必要があります。
「4より大きいか」と問うと、回答がどちらであれ、候補の半分を除外できます。その後、さらに半分に分割し続けると、候補数は 8 → 4 → 2 → 1 と変化していきます。以下では、答えが 7 となる特定の経路を固定して示します。他の答えについても、ちょうど3回の質問で確定します。
図を準備しています 再読み込み
1つの答えが、どのように 3 bit の情報になるか 一様分布の8つの候補が、この回答経路に沿って 4、2、1 個へと減っていきます。毎回残りの確率質量を半分にすることで 1 bit を得ますが、これは論理的なステップであり、物理的な時間ではありません。
{"id":"entropy-candidates","title":"1つの答えが、どのように 3 bit の情報になるか","summary":"一様分布の8つの候補が、この回答経路に沿って 4、2、1 個へと減っていきます。毎回残りの確率質量を半分にすることで 1 bit を得ますが、これは論理的なステップであり、物理的な時間ではありません。","height":600,"html":"<div class=\"eyebrow\" data-i18n=\"eyebrow\"></div>\n<h2 data-i18n=\"heading\"></h2>\n<p class=\"hint\" data-i18n=\"intro\"></p>\n<div class=\"candidates\" role=\"group\" data-i18n-label=\"candidates\"></div>\n<div class=\"metrics\">\n <div class=\"metric\"><strong id=\"remaining\">8</strong><span data-i18n=\"remaining\"></span></div>\n <div class=\"metric\"><strong id=\"uncertainty\">3 bit</strong><span data-i18n=\"uncertainty\"></span></div>\n <div class=\"metric\"><strong id=\"received\">0 bit</strong><span data-i18n=\"received\"></span></div>\n</div>\n<div class=\"history\" data-i18n-label=\"history\"></div>\n<div class=\"readout\" id=\"explanation\" role=\"status\" aria-live=\"polite\"></div>\n<div class=\"toolbar\">\n <button type=\"button\" data-prev data-i18n=\"prev\"></button>\n <button type=\"button\" class=\"primary\" data-next data-i18n=\"next\"></button>\n <button type=\"button\" data-play data-i18n=\"play\" aria-pressed=\"false\"></button>\n <span data-step></span>\n</div>","css":".candidates { display:grid; grid-template-columns:repeat(8,minmax(0,1fr)); gap:8px; margin-top:24px; }\n.candidate { display:grid; place-items:center; height:62px; border:1px solid var(--accent); background:var(--accent-soft); color:var(--accent); border-radius:6px; font-size:23px; transition:opacity .45s,transform .45s,background .45s; }\n.candidate.excluded { opacity:.28; transform:scale(.88); border-color:var(--rule); background:var(--surface); color:var(--muted); text-decoration:line-through; }\n.candidate.found { background:var(--accent); color:var(--paper); }\n.history { display:grid; gap:6px; }\n.history-row { display:flex; align-items:center; gap:12px; font-size:14px; opacity:.32; transition:opacity .3s; }\n.history-row.current { opacity:1; }\n.history-step { width:22px; color:var(--muted); font-variant-numeric:tabular-nums; }\n.history-track { flex:1; display:grid; grid-template-columns:repeat(8,1fr); gap:2px; height:8px; }\n.history-track i { background:var(--rule); border-radius:2px; }\n.history-track i.kept { background:var(--accent); }\n.history-value { width:42px; text-align:right; color:var(--muted); }\n@media(max-width:480px) { .candidates { gap:4px; } .candidate { height:48px; font-size:20px; } }","js":"const states = [[1,2,3,4,5,6,7,8],[5,6,7,8],[7,8],[7]];\nconst grid = document.querySelector('.candidates'), history = document.querySelector('.history');\nfor (let n=1;n<=8;n++) {const cell=document.createElement('div');cell.className='candidate';cell.textContent=n;grid.append(cell);}\nstates.forEach((state,index)=>{\n const row=document.createElement('div');row.className='history-row';\n const label=document.createElement('span');label.className='history-step';label.textContent=index;\n const track=document.createElement('div');track.className='history-track';track.setAttribute('aria-hidden','true');\n for(let n=1;n<=8;n++){const bit=document.createElement('i');bit.classList.toggle('kept',state.includes(n));track.append(bit);}\n const value=document.createElement('span');value.className='history-value';value.textContent=state.length;\n row.append(label,track,value);history.append(row);\n});\nviz.sequence({count:4,render(step){\n [...grid.children].forEach((cell,index)=>{\n const kept=states[step].includes(index+1);\n cell.classList.toggle('excluded',!kept);cell.classList.toggle('found',step===3&&kept);\n cell.setAttribute('aria-label',`${index+1} · ${viz.t(kept?'kept':'excluded')}`);\n });\n [...history.children].forEach((row,index)=>row.classList.toggle('current',index<=step));\n document.querySelector('#remaining').textContent=states[step].length;\n document.querySelector('#uncertainty').textContent=`${3-step} bit`;\n document.querySelector('#received').textContent=`${step} bit`;\n document.querySelector('#explanation').textContent=viz.t('step'+step);\n}});","audio":false,"strings":{"candidates":"数字の候補","excluded":"除外済み","eyebrow":"01 / 可能性から確定へ","heading":"各情報に可視的な帰属を持たせる","history":"各ステップでの候補変化を保持","intro":"数字 7 の経路に沿って展開します。まず全候補を表示し、その後回答を段階的に明らかにします。","kept":"依然として可能","next":"次へ","pause":"一時停止","play":"再生","prev":"前へ","received":"受信済み情報","remaining":"残り候補","step0":"回答はまだ受信していません。8つの数字は等確率であり、そのうちの1つを確認するには 3 bit の情報が必要です。","step1":"質問:4より大きいか? 回答:はい。1–4 を除外し、候補は8個から4個になり、1 bit を獲得。","step2":"質問:6より大きいか? 回答:はい。既知の回答を条件とし、候補は4個から2個になり、さらに 1 bit を獲得。","step3":"質問:7より大きいか? 回答:いいえ。数字 7 のみ残ります。累計 3 bit を獲得し、残りの不確実性は 0 になります。","uncertainty":"残りの不確実性"}}
1回の回答がもたらす情報の量は、それが除外した確率質量の量に依存します。 この例では、各回答は当時の条件で 1/2 の確率を持つため、それぞれが 1 bit をもたらします。3回合計で log 2 8 = 3 bit となります。
この結論には「等確率」と「毎回半分に分割する」という前提が必要です。もし数字 7 の確率が 0.8 で、他の7つの数字がそれぞれ 0.2/7 である場合、「7かどうか」を最初に問うことで、多くのケースで1回で終了できます。このとき、「はい」と「いいえ」はそれぞれ約 0.322 bit と 2.322 bit の情報を含みます。真偽問題は、各回答がちょうど 1 bit の情報をもたらすことを保証するものではありません。
自己情報:ある事象の確認で、どれだけの情報が得られるか
確率 p ( x ) > 0 を持つ結果 x が発生した場合、その自己情報 は以下のように定義されます:
I ( x ) = − log 2 p ( x )
より稀な事象ほど、それが発生したことを確認することでより多くの情報が得られます。確率が 1 の事象の自己情報は 0 です:モデルによってすでに確定している結果には、不確実性をさらに解消する余地がありません。
モデル内での事象の確率 自己情報 解釈
1/2 1 bit等確率の2択の1つを確認
1/8 3 bit8つの等確率候補の1つを確認
1/100 約 6.644 bit 一般的な事象よりも多くの情報を含む
1 0 bit結果はすでに確定している
なぜ対数を使うのでしょうか?独立な事象の結合確率は積になりますが、それらを確認する情報量は足し算になることを望みます:
I ( x , y ) = − log 2 [ p ( x ) p ( y )] = I ( x ) + I ( y )
独立でない場合でも足し算できますが、第二項には条件確率を使用する必要があります:
− log 2 p ( x , y ) = − log 2 p ( x ) − log 2 p ( y ∣ x )
自己情報は小数になることがあります。これは「実際に 0.322 回質問した」という意味ではなく、また独立した2進符号語が小数桁の長さを必要とするわけでもありません。実際の質問回数と符号化長の関係については、後ほど議論します。
エントロピー:各結果の情報量を確率で重み付け
自己情報は特定の結果を対象とします。エントロピー は全体の分布を対象とし、自己情報の期待値です:
H ( X ) = E [ I ( X )] = − x ∑ p ( x ) log 2 p ( x )
同じ分布から独立に繰り返しサンプリングすると想像してください。一般的な結果は頻繁に平均に含まれますが、稀な結果は1回あたりの情報量は大きくても、出現頻度は低いです。したがって、各結果の自己情報を単純に足し合わせることはできません。まず発生確率を掛ける必要があります。
ここでは結果を2つに限定します:P ( A ) = p 、P ( B ) = 1 − p 。対応する二元エントロピー関数は以下の通りです:
h 2 ( p ) = − p log 2 p − ( 1 − p ) log 2 ( 1 − p )
まず確率全体の範囲での傾向を見てみましょう。曲線の横軸は p 、縦軸は2つの寄与の和 h 2 ( p ) です。
h₂(p)
1
0
0.5
1
p
1 bit
両端の結果は完全に確定しており、エントロピーはゼロです。各が半分ずつのときが最も予測が難しく、エントロピーは 1 bit に達します。曲線は左右対称です。結果の名前を交換しても不確実性は変わらないからです。
次に、曲線上の1点を分解してみましょう。確率を変化させ、各長方形の幅、高さ、面積を観察し、これら2つの寄与がどのように足し合わされるかを理解します。
図を準備しています 再読み込み
稀なほど高くなり、狭くなる A の確率をドラッグすると、青と金色のブロックが同時に変化します。幅は確率、高さは単発の自己情報、面積はエントロピーへの寄与です。2つの面積を足し合わせると平均情報量が得られます。
{"id":"entropy-probability","title":"稀なほど高くなり、狭くなる","summary":"A の確率をドラッグすると、青と金色のブロックが同時に変化します。幅は確率、高さは単発の自己情報、面積はエントロピーへの寄与です。2つの面積を足し合わせると平均情報量が得られます。","height":1040,"html":"<div class=\"eyebrow\" data-i18n=\"eyebrow\"></div>\n<h2 data-i18n=\"heading\"></h2>\n<p class=\"hint\" data-i18n=\"intro\"></p>\n<div class=\"probability-control\"><label for=\"probability\" data-i18n=\"probability\"></label><output id=\"probability-value\" for=\"probability\"></output></div>\n<input id=\"probability\" type=\"range\" min=\"0\" max=\"100\" step=\"1\" value=\"90\">\n<div class=\"range-labels\" aria-hidden=\"true\"><span>0%</span><span>50%</span><span>100%</span></div>\n<div class=\"entropy-total\">\n <div class=\"total-heading\"><span data-i18n=\"totalMeaning\"></span><strong>H = <output id=\"entropy\"></output> <small>bit</small></strong></div>\n <div class=\"total-track\" role=\"img\" data-i18n-label=\"totalLabel\"><span id=\"total-a\"></span><span id=\"total-b\"></span></div>\n <div class=\"total-scale\"><span>0 bit</span><span>1 bit</span></div>\n</div>\n\n<div class=\"outcome-labels\">\n <div class=\"outcome-a\"><strong>A</strong><span id=\"label-a\"></span><span id=\"info-a\"></span></div>\n <div class=\"outcome-b\"><strong>B</strong><span id=\"label-b\"></span><span id=\"info-b\"></span></div>\n</div>\n<div class=\"axis-heading\" data-i18n=\"heightMeaning\"></div>\n<div class=\"chart-shell\">\n <div class=\"information-chart\" role=\"img\" data-i18n-label=\"chartLabel\">\n <span class=\"grid-line top\"><i>7</i></span><span class=\"grid-line middle\"><i>3.5</i></span><span class=\"grid-line bottom\"><i>0</i></span>\n <div class=\"area area-a\" id=\"area-a\"></div><div class=\"area area-b\" id=\"area-b\"></div>\n <div class=\"division\" id=\"division\"></div>\n </div>\n <div class=\"frequency-band\" aria-hidden=\"true\"><span id=\"frequency-a\"></span><span id=\"frequency-b\"></span></div>\n <div class=\"probability-axis\"><span>0</span><span data-i18n=\"widthMeaning\"></span><span>1</span></div>\n</div>\n<p class=\"area-meaning\" data-i18n=\"areaMeaning\"></p>\n<div class=\"probability-readout\" aria-live=\"polite\">\n <p id=\"probability-explanation\"></p><p class=\"reserve\" data-i18n=\"middle\" aria-hidden=\"true\"></p><p class=\"reserve\" data-i18n=\"offcenter\" aria-hidden=\"true\"></p><p class=\"reserve\" data-i18n=\"endpoint\" aria-hidden=\"true\"></p>\n</div>\n<details class=\"audit-details\"><summary data-i18n=\"detailLabel\"></summary><div class=\"contributions\">\n <div class=\"contribution contribution-a\"><span class=\"contribution-heading\"><strong>A</strong><span data-i18n=\"contribution\"></span></span><div class=\"expression\"><span id=\"contribution-a\"></span><span class=\"reserve\" aria-hidden=\"true\">0.99 × 6.64 ≈ 0.99 bit</span><span class=\"reserve\" aria-hidden=\"true\">lim −p log₂p → 0 bit</span></div></div>\n <div class=\"contribution contribution-b\"><span class=\"contribution-heading\"><strong>B</strong><span data-i18n=\"contribution\"></span></span><div class=\"expression\"><span id=\"contribution-b\"></span><span class=\"reserve\" aria-hidden=\"true\">0.99 × 6.64 ≈ 0.99 bit</span><span class=\"reserve\" aria-hidden=\"true\">lim −p log₂p → 0 bit</span></div></div>\n</div>\n<p class=\"model-note\" data-i18n=\"modelNote\"></p></details>","css":".probability-control { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:24px; }\n.range-labels { display:flex; justify-content:space-between; color:var(--muted); font-size:10px; font-variant-numeric:tabular-nums; }\n.outcome-labels { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; margin:24px 0; font-size:13px; font-variant-numeric:tabular-nums; }\n.outcome-labels > div { display:grid; grid-template-columns:auto 1fr; gap:2px 9px; align-items:center; }\n.outcome-labels strong { display:grid; grid-row:span 2; place-items:center; width:30px; height:36px; border-radius:6px; background:var(--accent-soft); }\n.outcome-labels span { white-space:nowrap; }\n.outcome-a { color:var(--accent); } .outcome-b { color:var(--second); }\n.outcome-b strong { background:var(--second-soft); }\n.axis-heading { margin-bottom:12px; color:var(--muted); font-size:12px; }\n.chart-shell { padding-left:28px; }\n.information-chart { position:relative; height:224px; border-left:1px solid var(--rule); }\n.grid-line { position:absolute; inset-inline:0; height:0; border-top:1px solid var(--rule); }\n.grid-line i { position:absolute; left:-29px; width:23px; text-align:right; transform:translateY(-50%); color:var(--muted); font-size:11px; font-style:normal; }\n.grid-line.top { top:0; } .grid-line.middle { top:50%; border-top-style:dashed; opacity:.7; } .grid-line.bottom { bottom:0; }\n.area { position:absolute; bottom:0; box-sizing:border-box; box-shadow:inset 0 0 0 1px currentColor; transition:width .35s ease,height .35s ease,opacity .2s ease; background:var(--accent-soft); }\n.area::after { content:''; position:absolute; inset:0; opacity:.1; background:repeating-linear-gradient(135deg,transparent 0 7px,currentColor 7px 8px); }\n.area-a { left:0; color:var(--accent); }\n.area-b { right:0; color:var(--second); background:var(--second-soft); }\n.division { position:absolute; top:0; bottom:0; width:0; border-left:1px dashed var(--muted); opacity:.35; transition:left .35s ease; }\n.frequency-band { display:flex; height:5px; margin-top:5px; overflow:hidden; border-radius:2px; }\n.frequency-band span { display:block; transition:width .35s ease; }\n#frequency-a { background:var(--accent); } #frequency-b { background:var(--second); }\n.probability-axis { display:flex; justify-content:space-between; align-items:baseline; gap:10px; font-size:11px; color:var(--muted); margin-top:8px; }\n.probability-axis > span:nth-child(2) { text-align:center; }\n.area-meaning { text-align:center; margin:20px 0; font-size:13px; color:var(--muted); }\n.contributions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }\n.contribution { padding:12px; border:1px solid var(--rule); border-radius:8px; min-width:0; }\n.contribution-a { color:var(--accent); } .contribution-b { color:var(--second); }\n.contribution-heading { display:flex; flex-wrap:wrap; gap:4px 8px; align-items:center; font-size:12px; margin-bottom:5px; }\n.expression { display:grid; font-size:13px; line-height:1.7; font-variant-numeric:tabular-nums; }\n.expression > span { grid-area:1 / 1; min-width:0; }\n.reserve { visibility:hidden; pointer-events:none; user-select:none; }\n.entropy-total { margin-top:24px; padding-top:18px; border-top:1px solid var(--rule); }\n.total-heading { display:flex; align-items:baseline; justify-content:space-between; flex-wrap:wrap; gap:8px 16px; }\n.total-heading > span { color:var(--muted); font-size:13px; }\n.total-heading strong { font-size:23px; font-weight:500; white-space:nowrap; font-variant-numeric:tabular-nums; }\n.total-heading small { font-size:13px; font-weight:400; color:var(--muted); }\n.total-track { display:flex; height:16px; margin-top:12px; border-radius:3px; overflow:hidden; background:var(--surface); }\n.total-track > span { height:100%; transition:width .35s ease; }\n#total-a { background:var(--accent); } #total-b { background:var(--second); }\n.total-scale { display:flex; justify-content:space-between; font-size:10px; color:var(--muted); margin-top:5px; }\n.probability-readout { display:grid; font-size:13px; line-height:1.7; margin-top:18px; }\n.probability-readout > p { grid-area:1 / 1; min-width:0; }\n.model-note { font-size:11px; color:var(--muted); margin-top:16px; line-height:1.7; }\n@media(max-width:480px) { .outcome-labels { gap:10px; font-size:11px; } .outcome-labels strong { width:24px; } .contributions { gap:8px; } .contribution { padding:10px; } .expression { font-size:12px; } .information-chart { height:200px; } }\n.entropy-total { margin-top:12px; padding-top:10px; }.outcome-labels { margin:16px 0; }.area-meaning { margin:12px 0; }.probability-readout { margin-top:12px; }\n@media(max-width:480px){.information-chart{height:150px}.outcome-labels{margin:12px 0}.axis-heading{margin-bottom:8px}.total-heading strong{font-size:21px}.contributions{margin-top:10px}.chart-shell{padding-left:28px}}\n\n.audit-details { border-top:1px solid var(--rule); margin-top:14px; padding-top:8px; }\n.audit-details summary { cursor:pointer; color:var(--accent); font-size:13px; min-height:36px; padding:6px 0; }\n.audit-details summary:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }\n.audit-details .formula { border:0; margin-top:8px; padding:8px 0; }\n","js":"const slider=document.querySelector('#probability');\nfunction draw(){\n const p=Number(slider.value)/100,q=1-p;\n const ia=p>0?-Math.log2(p):Infinity,ib=q>0?-Math.log2(q):Infinity;\n const ca=p>0?p*ia:0,cb=q>0?q*ib:0,h=ca+cb;\n const info=x=>Number.isFinite(x)?viz.number(x):'∞';\n document.querySelector('#probability-value').textContent=viz.number(p*100,0)+'%';\n for(const [key,chance,value,contribution] of [['a',p,ia,ca],['b',q,ib,cb]]){\n document.querySelector('#label-'+key).textContent=`p = ${viz.number(chance)}`;\n document.querySelector('#info-'+key).textContent=`I = ${info(value)} bit`;\n const area=document.querySelector('#area-'+key);\n area.style.width=`${chance*100}%`;\n area.style.height=`${Number.isFinite(value)?100*value/7:0}%`;\n area.style.opacity=chance===0||value===0?'0':'1';\n document.querySelector('#frequency-'+key).style.width=`${chance*100}%`;\n document.querySelector('#total-'+key).style.width=`${contribution*100}%`;\n document.querySelector('#contribution-'+key).textContent=chance===0?'lim −p log₂p → 0 bit':`${viz.number(chance)} × ${info(value)} ≈ ${viz.number(contribution)} bit`;\n }\n document.querySelector('#division').style.left=`${p*100}%`;\n document.querySelector('#entropy').textContent=viz.number(h);\n document.querySelector('#probability-explanation').textContent=viz.t(p===0||p===1?'endpoint':p===.5?'middle':'offcenter');\n document.querySelector('.information-chart').setAttribute('aria-label',`${viz.t('chartLabel')} A: p=${viz.number(p)}, I=${info(ia)} bit; B: p=${viz.number(q)}, I=${info(ib)} bit.`);\n document.querySelector('.total-track').setAttribute('aria-label',`${viz.t('totalLabel')} A: ${viz.number(ca)} bit; B: ${viz.number(cb)} bit; H=${viz.number(h)} bit.`);\n}\nslider.addEventListener('input',draw);\ndraw();","audio":false,"strings":{"areaMeaning":"幅 × 高さ = 確率 × 自己情報 = エントロピーへの寄与","chartLabel":"確率と自己情報の面積図:青が A、金色が B。幅は確率、高さは自己情報、面積はエントロピーへの寄与。","contribution":"面積 · p × I","detailLabel":"項目ごとの計算とモデルの規約を表示","endpoint":"結果が完全に確定している場合、必然的な結果の高さは 0 になる。不可能な結果の幅は 0 であり、自己情報は形式的に ∞ だが、寄与は極限として 0 と定義される。2つの面積はともに 0 であり、エントロピーも 0 である。","eyebrow":"02 / 面積で重み付け平均を見る","heading":"稀な事象の情報量は大きいのに、なぜ平均は小さくなるのか?","heightMeaning":"高さ = 単発自己情報 I · bit","intro":"A の確率のみを変更します。同じ色に沿って見てみましょう:どのくらい広く、どのくらい高く、面積はどのくらいか。","middle":"2つの結果が同様に一般的。各ブロックは幅 0.5、高さ 1 で、それぞれ 0.5 bit を寄与。合わせると 1 bit となり、二元エントロピーは最大になる。","modelNote":"ここでは確率を直接計算しており、サンプリングの揺らぎはない。メインチャートの高さは 0–7 bit で固定。下部の寄与バーの最大値は 1 bit で固定。","offcenter":"低確率の結果のブロックは高くなるが、より狭くなる。面積は幅と高さの両方に依存するため、単発の情報量が増えたからといって、平均情報量が増えるわけではない。","probability":"A の発生確率","totalLabel":"2つの結果のエントロピーへの寄与の和。最大値は 1 bit。","totalMeaning":"2つの面積を足し合わせると、エントロピーが得られる","widthMeaning":"幅 = 発生確率 p"}}
p = 0.5 のとき、2つの結果はそれぞれ 1 bit の自己情報を持ち、重み付け後それぞれ 0.5 bit を寄与し、エントロピーは最大で 1 bit になります。どちらかに偏ると、稀な結果はより予想外になりますが、分布全体の平均不確実性は低下します。p = 0 または 1 に至ると、結果は完全に確定し、エントロピーは 0 になります。
ここでは 0 log 2 0 = 0 と規定します。これは lim p → 0 + p log 2 p = 0 に基づきます。確率がゼロの事象はモデル内で発生しません。もし現実でそれが発生した場合、それを通常の有限の自己情報サンプルとして扱うのではなく、モデルを見直す必要があります。
エントロピーと実際の質問回数を直接等号で結べない
自己情報とエントロピーは小数になり得ますが、1回の実際の真偽質問は1回としてカウントされます。符号ごとの接頭符号化の最適平均長は H ( X ) ≤ L ∗ < H ( X ) + 1 を満たします(正の確率を持つ結果が少なくとも2つある場合)。したがって自己情報、エントロピー、平均符号長、最悪の質問回数は異なる量 です。
ここではその違いを覚えておきましょう。公平なサイコロの意思決定木、切り捨てのオーバーヘッド、およびブロック符号化については、ソース符号化と圧縮 で説明します。
結合エントロピー、条件エントロピー、相互情報
2つの変数間の問いはこうです:手がかりを見た後、まだどれくらい分からないのか? 「平均」の役割を明確にするため、今回は Y が一様でないようにします:P ( Y = 1 ) = 0.1 、P ( Y = 0 ) = 0.9 。手がかり X = Y ⊕ N は、独立ノイズ N によって元の値が確率 q で反転します。
デフォルトでは q = 0.1 とします。X = 1 を観測した場合、それは稀な Y = 1 が正しく保持されたか、あるいは一般的な Y = 0 が反転されたかのどちらかです。両ケースの結合確率はともに 0.09 であるため、この分岐はかえって五分五分になります。もう一方の分岐はどうなるでしょうか?これらをどのように平均化するべきでしょうか?
図を準備しています 再読み込み
各分岐は異なる。条件エントロピーはどのように平均化されるか? 結合確率は X によって2行に分割され、それぞれ条件分布に正規化されます。各分岐のエントロピーに分岐の確率を掛けて足し合わせると条件エントロピーが得られます。ある分岐がより不確実でも、平均不確実性の低下は妨げられません。
{"id":"entropy-conditioning","title":"各分岐は異なる。条件エントロピーはどのように平均化されるか?","summary":"結合確率は X によって2行に分割され、それぞれ条件分布に正規化されます。各分岐のエントロピーに分岐の確率を掛けて足し合わせると条件エントロピーが得られます。ある分岐がより不確実でも、平均不確実性の低下は妨げられません。","height":1100,"html":"<p class=\"eyebrow\" data-i18n=\"eyebrow\"></p><h2 data-i18n=\"heading\"></h2><p class=\"intro\" data-i18n=\"intro\"></p>\n<div class=\"presets\" role=\"group\" data-i18n-label=\"priorLabel\"><button data-prior=\"10\" data-i18n=\"skewed\"></button><button data-prior=\"50\" data-i18n=\"balanced\"></button></div>\n<label class=\"control\" for=\"noise\"><span data-i18n=\"noise\"></span><output id=\"noise-value\"></output></label><input id=\"noise\" type=\"range\" min=\"0\" max=\"100\" value=\"10\">\n<div class=\"presets\" role=\"group\" data-i18n-label=\"noise\"><button data-noise=\"0\" data-i18n=\"copy\"></button><button data-noise=\"50\" data-i18n=\"independent\"></button><button data-noise=\"100\" data-i18n=\"inverted\"></button></div>\n<div class=\"prior-line\"><span id=\"prior-distribution\"></span><strong id=\"prior-entropy\"></strong></div>\n<div class=\"joint\"><div class=\"joint-row\"><span>P(X,Y)</span><span>Y=0</span><span>Y=1</span><span>P(X)</span></div><div class=\"joint-row\"><strong>X=0</strong><span id=\"cell00\"></span><span id=\"cell01\"></span><strong id=\"weight0\"></strong></div><div class=\"joint-row\"><strong>X=1</strong><span id=\"cell10\"></span><span id=\"cell11\"></span><strong id=\"weight1\"></strong></div></div>\n<p class=\"note\" data-i18n=\"jointNote\"></p>\n<div class=\"branches\"><section class=\"branch\" id=\"branch0\"><h3>Y | X=0</h3><div class=\"posterior\" aria-hidden=\"true\"><div id=\"posterior0\"></div><div class=\"second\" id=\"posterior01\"></div></div><p class=\"distribution\" id=\"distribution0\"></p><strong id=\"entropy0\"></strong><p class=\"branch-change\"><span data-i18n=\"more\"></span></p></section><section class=\"branch\" id=\"branch1\"><h3>Y | X=1</h3><div class=\"posterior\" aria-hidden=\"true\"><div id=\"posterior10\"></div><div class=\"second\" id=\"posterior11\"></div></div><p class=\"distribution\" id=\"distribution1\"></p><strong id=\"entropy1\"></strong><p class=\"branch-change\"><span data-i18n=\"more\"></span></p></section></div>\n<div class=\"formula\"><div>H(Y|X) = P(X=0) H(Y|X=0) + P(X=1) H(Y|X=1)</div><div id=\"weighted-formula\"></div></div>\n<div class=\"contributions\" role=\"img\" data-i18n-label=\"contributions\"><div id=\"contribution0\"></div><div id=\"contribution1\"></div></div><div class=\"scale\"><span>0 bit</span><span>1 bit</span></div><div class=\"legend\"><span class=\"blue\">X=0</span><span class=\"gold\">X=1</span></div>\n<div class=\"metric-pair\"><div><span>H(Y|X) · bit</span><strong id=\"conditional\"></strong></div><div><span>I(X;Y) · bit</span><strong id=\"mutual\"></strong></div></div>\n<div class=\"formula\"><div id=\"mutual-formula\"></div><div id=\"chain-formula\"></div></div><p class=\"note\" data-i18n=\"note\"></p>\n","css":".intro { margin:8px 0 18px; color:var(--muted); font-size:14px; }\n.control { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:18px; }\n.control output { min-width:4em; flex-shrink:0; text-align:center; background:var(--accent-soft); color:var(--accent); padding:2px 8px; border-radius:6px; font-weight:600; }\n.formula { margin-top:18px; padding:14px 0; border-block:1px solid var(--rule); font-size:16px; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }\n.copy-stack { display:grid; margin-top:14px; color:var(--muted); font-size:14px; }\n.copy-stack > * { grid-area:1/1; }\n.copy-stack .reserve { visibility:hidden; }\n.note { margin-top:14px; color:var(--muted); font-size:12px; }\n.metric-pair { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:18px; }\n.metric-pair > div { min-width:0; }\n.metric-pair span { display:block; font-size:12px; color:var(--muted); }\n.metric-pair strong { display:block; font-size:24px; font-weight:500; font-variant-numeric:tabular-nums; }\n.scale { display:flex; justify-content:space-between; color:var(--muted); font-size:12px; font-variant-numeric:tabular-nums; }\n@media(max-width:480px) { .metric-pair strong { font-size:21px; } }\n.presets { display:flex; }\n.plot { position:relative; margin-top:18px; height:190px; border-left:1px solid var(--rule); border-bottom:1px solid var(--muted); }\n.plot svg { width:100%; height:100%; overflow:hidden; }\n.plot .curve { fill:none; stroke:var(--accent); stroke-width:2.5; vector-effect:non-scaling-stroke; }\n.plot .curve.secondary { stroke:var(--second); stroke-dasharray:5 4; }\n.scale { position:relative; }.scale .middle { position:absolute; left:50%; transform:translateX(-50%); }\n.formula { font-size:14px; }.formula div+div { margin-top:6px; }\n@media(max-width:480px) { .plot { height:170px; } }\n.plot .curve { transition:d .28s cubic-bezier(.22,1,.36,1); }\n.band { display:flex; height:28px; border-radius:5px; overflow:hidden; background:var(--surface); margin-top:10px; }\n.band > div { background:var(--accent); transition:width .28s ease; }\n.band > .gold { background:var(--second); }\n.legend { display:flex; flex-wrap:wrap; gap:6px 18px; margin-top:10px; font-size:12px; color:var(--muted); }\n.legend .blue::before,.legend .gold::before { content:''; display:inline-block; width:9px; height:9px; border-radius:2px; margin-right:6px; background:var(--accent); }\n.legend .gold::before { background:var(--second); }\n.rows { margin-top:18px; display:grid; gap:12px; }\n.row { display:grid; grid-template-columns:32px 1fr 60px; align-items:center; gap:10px; font-size:13px; }\n.row > div { min-width:0; }.row output { text-align:right; font-variant-numeric:tabular-nums; }\n.track { height:14px; background:var(--surface); border-radius:3px; overflow:hidden; }\n.fill { height:100%; width:0; background:var(--accent); transition:width .28s ease; }\n.presets { flex-wrap:wrap; gap:4px; }.presets button { min-width:0; }\n.metric-pair strong { overflow-wrap:anywhere; }\n.presets button { flex:1 1 auto; min-width:min-content; }\n.presets { margin-top:10px; }.prior-line { display:flex; flex-wrap:wrap; gap:6px 16px; justify-content:space-between; margin-top:22px; font-size:13px; }.joint { margin-top:16px; }.joint-row { display:grid; grid-template-columns:1fr 1fr 1fr 1fr; text-align:center; border-bottom:1px solid var(--rule); padding:9px 0; font-size:13px; font-variant-numeric:tabular-nums; }.joint-row:first-child { color:var(--muted); }.branches { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:18px; }.branch { border:1px solid var(--rule); border-radius:8px; padding:14px; min-width:0; transition:border-color .28s,background .28s; }.branch h3 { margin:0; font-size:15px; }.branch.increased { border-color:var(--second); background:var(--second-soft); }.posterior { display:flex; height:24px; margin-top:14px; border-radius:4px; overflow:hidden; }.posterior > div { background:var(--accent); transition:width .28s ease; }.posterior .second { background:var(--second); }.distribution { font-size:12px; color:var(--muted); margin:8px 0; }.branch > strong { font-size:20px; font-variant-numeric:tabular-nums; }.branch-change { margin:8px 0 0; font-size:12px; color:var(--second); }.branch-change span { visibility:hidden; }.increased .branch-change span { visibility:visible; }.contributions { display:flex; height:24px; background:var(--surface); border-radius:4px; overflow:hidden; margin-top:14px; }.contributions div { background:var(--accent); transition:width .28s ease; }#contribution1 { background:var(--second); }\n@media(max-width:480px) { .branch { padding:10px; }.branch > strong { font-size:18px; }.joint-row { font-size:12px; }.distribution { font-size:11px; }.formula { font-size:13px; } }\n","js":"const $=s=>document.querySelector(s),h=p=>viz.entropy([p,1-p]);let a=.1;\nfunction draw(){const q=+$('#noise').value/100,joint=[[(1-a)*(1-q),a*q],[(1-a)*q,a*(1-q)]],weights=joint.map(r=>r[0]+r[1]),posterior=joint.map((r,i)=>r[1]/weights[i]),entropies=posterior.map(h),terms=entropies.map((v,i)=>v*weights[i]),conditional=terms[0]+terms[1],prior=h(a),mi=Math.max(0,prior-conditional),hx=viz.entropy(weights);\n $('#noise-value').textContent=viz.number(q,2);$('#prior-distribution').textContent='P(Y) = ('+viz.number(1-a,1)+', '+viz.number(a,1)+')';$('#prior-entropy').textContent='H(Y) = '+viz.number(prior,3)+' bit';\n for(let i=0;i<2;i++){for(let y=0;y<2;y++)$('#cell'+i+y).textContent=viz.number(joint[i][y],3);$('#weight'+i).textContent=viz.number(weights[i],3);$(i?'#posterior10':'#posterior0').style.width=(1-posterior[i])*100+'%';$('#posterior'+i+'1').style.width=posterior[i]*100+'%';$('#distribution'+i).textContent='('+viz.number(1-posterior[i],3)+', '+viz.number(posterior[i],3)+')';$('#entropy'+i).textContent=viz.number(entropies[i],3)+' bit';$('#branch'+i).classList.toggle('increased',entropies[i]>prior+1e-10);$('#contribution'+i).style.width=terms[i]*100+'%';}\n $('#weighted-formula').textContent='≈ '+viz.number(weights[0],3)+' × '+viz.number(entropies[0],3)+' + '+viz.number(weights[1],3)+' × '+viz.number(entropies[1],3)+' ≈ '+viz.number(conditional,3)+' bit';$('#conditional').textContent=viz.number(conditional,3);$('#mutual').textContent=viz.number(mi,3);\n $('#mutual-formula').textContent='I(X;Y) = H(Y) − H(Y|X) ≈ '+viz.number(prior,3)+' − '+viz.number(conditional,3)+' = '+viz.number(mi,3)+' bit';$('#chain-formula').textContent='H(X,Y) = H(X) + H(Y|X) ≈ '+viz.number(hx,3)+' + '+viz.number(conditional,3)+' = '+viz.number(hx+conditional,3)+' bit';\n document.querySelectorAll('[data-prior]').forEach(e=>e.setAttribute('aria-pressed',String(+e.dataset.prior===a*100)));document.querySelectorAll('[data-noise]').forEach(e=>e.setAttribute('aria-pressed',String(+e.dataset.noise===+$('#noise').value)));}\n$('#noise').addEventListener('input',draw);document.querySelectorAll('[data-prior]').forEach(e=>e.addEventListener('click',()=>{a=+e.dataset.prior/100;draw();}));document.querySelectorAll('[data-noise]').forEach(e=>e.addEventListener('click',()=>{$('#noise').value=e.dataset.noise;draw();}));draw();\n","audio":false,"strings":{"balanced":"一様な事前分布","contributions":"0–1 bit の目盛りを固定し、2つの幅はそれぞれ P(X=x)H(Y|X=x)、総長は平均条件エントロピー。","copy":"完全に同一","eyebrow":"03 / 1つとすべての手がかり","heading":"各分岐は異なる。条件エントロピーはどのように平均化されるか?","independent":"互いに独立","intro":"まず Y の事前分布を見てから、X の2つの分岐をすべて保持します。青/金色は Y=0/1 を表す。下部の寄与バーでは X=0/1 を区別するために別の青/金色を使用。","inverted":"完全に逆","jointNote":"4つのセルは結合確率、右列は行和。各行を自分の行和で割って初めて、下部の条件分布が得られる。","more":"事前分布よりも不確実性が高い","noise":"独立反転確率 q","note":"寄与バーの各セグメントは分岐確率 × 分岐エントロピーであり、固定された 0–1 bit の目盛りを使用。金色の枠は事前分布よりも不確実性が高い分岐を示す。相互情報は事前分布と全分岐の平均を比較する。","priorLabel":"Y の事前分布","skewed":"偏った事前分布"}}
条件エントロピー:各手がかりは発生確率でカウントする
表の各行を自分の行和で割ると、P ( Y ∣ X = x ) が得られます。これは特定の具体的な手がかりを観測した ことに相当します。条件エントロピーは、すべての分岐のエントロピーを行の発生確率で重み付けする必要があります:
H ( Y ∣ X ) = x ∑ P ( X = x ) H ( Y ∣ X = x ) .
デフォルトの例では、X = 1 の発生確率は 0.18 で、この分岐のエントロピーは 1 bit です。X = 0 の発生確率は 0.82 で、この分岐のエントロピーは約 0.095 bit です。重み付け後、約 0.258 bit となり、2つの分岐の単純平均を取ることはできません。ましてや1つだけを見ることはなおさらできません。
一様な事前分布に切り替えると、2行はちょうど対称になり、分岐エントロピーはともに h 2 ( q ) になります。このとき、1行だけを計算すると偶然正しい平均値が得られますが、これはこの対称な例の特徴であり、一般的な規則ではありません。
結合エントロピー:まず手がかりを確定し、次に元の値を確定する
変数対 ( X , Y ) を1つの結果と見なすと、そのエントロピーは H ( X , Y ) = − ∑ x , y p ( x , y ) log 2 p ( x , y ) です。2段階で質問を明確にすることもできます:まず X を確定し、次にその分岐内で Y を確定します。これにより連鎖法則 が得られます:
H ( X , Y ) = H ( X ) + H ( Y ∣ X ) .
図の右側の行和は P ( X ) を構成し、第1ステップの H ( X ) を決定します。2つの条件分岐の重み付け平均が第2ステップの H ( Y ∣ X ) を決定します。これが下部の結合エントロピーの公式の2つの項の由来です。
また、p ( x , y ) = p ( x ) p ( y ∣ x ) から導くこともできます:負の対数を取ることで乗算を加算に変換し、結合確率で平均を取ります。独立の場合、H ( Y ∣ X ) = H ( Y ) となり、結合エントロピーは2つの周辺エントロピーの和に等しくなります。
相互情報:平均してどれだけの不確実性が減少したか
手がかりを観測する前、不確実性は H ( Y ) です。観測後、平均して残るのは H ( Y ∣ X ) です。この差が相互情報です:
I ( X ; Y ) = H ( Y ) − H ( Y ∣ X ) = H ( X ) + H ( Y ) − H ( X , Y ) .
デフォルトの例では、事前エントロピーは約 0.469 bit、平均条件エントロピーは約 0.258 bit であるため、相互情報は約 0.211 bit になります。1回の観測で不確実性が 1 bit に上昇することがあっても、すべての手がかりについて平均を取ると、不確実性は依然として減少します。
相互情報は対称で非負であり、2つの変数が独立である場合に限りゼロになります。これは H ( Y ∣ X ) ≤ H ( Y ) を意味しますが、各具体的な分岐が同じ不等式を満たすことを要求するものではありません。
q を 0.5 に調整すると、手がかりと元の値は独立になり、相互情報はゼロになります。0 または 1 に調整すると、手がかりは元の値を完全に決定でき、相互情報は H ( Y ) に等しくなります。完全に逆でも、完全に情報を提供し得ます。統計的依存性は値が同じであることを要求せず、自動的に因果関係を意味するわけではありません。
1つの図で情報計測を対照する
ここでの2つの有限離散変数について、ベン図を使って代数的関係を記憶できます。2つの円はそれぞれ H ( X ) と H ( Y ) を表し、重なり部分は I ( X ; Y ) 、和集合は H ( X , Y ) を表します。図の面積は示意のみであり、上記のノイズパラメータのいずれかの数値に対応するものではありません。
H(X)
H(Y)
H(X|Y)
H(Y|X)
I(X;Y)
H(X,Y)
左の円から H ( X ) = H ( X ∣ Y ) + I ( X ; Y ) が読み取れます。3つの互いに重ならない領域を足し合わせると、結合エントロピーが得られます。この図は前述の関係を一箇所にまとめ、対照しやすくしています。
これらの量を1つの表に戻す
量 対象 答える問い
I ( x ) 1つの発生した結果 この事象を確認することで、どれだけの情報が得られるか?
H ( X ) 1つの変数の分布 平均してどれだけの不確実性があるか?
H ( X , Y ) 2つの変数の結合分布 一緒に確定することで、どれだけの不確実性があるか?
H ( Y ∣ X ) 手がかりで重み付けされた条件分布 X を知った後、平均してどれくらい残っているか?
I ( X ; Y ) 2つの変数の依存関係 X を知った後、平均してどれだけの不確実性が解消されたか?
有限離散変数については、以下の2つの有用な境界があります:
H ( X ) ≥ 0 。結果が確定している場合にのみ等号が成立する。
取り得る値の集合の大きさが m の場合、H ( X ) ≤ log 2 m 。この m 個の値が一様分布している場合にのみ等号が成立する。
値の数は最大エントロピーを制約し、確率分布が実際のエントロピーを決定します。系列の場合、文脈依存性も考慮する必要があります。1文字の頻度分布と、前文を知った後の次の文字の分布は、同じ対象ではありません。両者の差異をすべて「頻度の高い文字が多いから」と帰因することはできません。
基礎的な主軸はここまで。詳細は必要に応じて読む
上記の表を理解できれば、次の章に進むのに十分です。系列の連鎖法則とエントロピー率は第3篇 で展開します。連続変数の密度、微分エントロピー、および座標スケールについては、第4篇 ガウスチャネル で紹介します。
「なぜ条件が依存関係を変えるのか」「処理によってどの情報が失われるのか」といった問いをさらに追及したい場合は、選択読本:条件情報とデータ処理 をお読みください。ここでは条件ごとのグループ化と状態のマージを用いて説明しますが、基礎的な読書の前提条件ではありません。
次篇:予測分布が不正確だと、どのような代償を払うのか
この篇では、常に与えられた分布自体を用いて情報量を計算しました。次篇では、「データが実際に生成された分布 p 」と「私たちが予測や符号化のために使用する分布 q 」を分離し、交差エントロピーと KL 発散 について説明します。
その後、シリーズは順に可逆圧縮 、ノイズのあるチャネル 、歪み許容圧縮 を議論し、最後に言語モデル に戻ります。
参考文献