When a message arrives, which possibilities does it rule out? What remains unknown? Information theory makes this change measurable. It measures uncertainty under a probability model, rather than directly measuring a statement’s meaning, truth, or usefulness.
We will follow three processes: replies eliminating candidates, individual information contributions forming an average, and one variable helping us understand another. All logarithms use base 2 and the unit is the bit. Unless stated otherwise, variables are finite and discrete.
From eight candidates to one answer
Let X take a value from 1 to 8, each equally likely. You may ask yes-or-no questions and must eventually identify the answer.
“Is it greater than 4?” eliminates half the candidates regardless of the reply. Continue dividing in half and the candidate count follows 8→4→2→1. The sequence below follows the fixed answer 7; every other answer also takes exactly three questions.
Preparing the visual
How one answer becomes 3 bits of information
Eight equally likely candidates become four, two, then one along this answer path. Each question halves the remaining probability mass and contributes 1 bit. These are logical steps, not physical time.
{"id":"entropy-candidates","title":"How one answer becomes 3 bits of information","summary":"Eight equally likely candidates become four, two, then one along this answer path. Each question halves the remaining probability mass and contributes 1 bit. These are logical steps, not physical time.","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":"Number candidates","excluded":"excluded","eyebrow":"01 / FROM POSSIBLE TO CERTAIN","heading":"See what each piece of information removes","history":"Candidate history at each step","intro":"This sequence follows the fixed answer 7. Start with all candidates, then reveal the replies.","kept":"still possible","next":"Next","pause":"Pause","play":"Play sequence","prev":"Previous","received":"Information gained","remaining":"Candidates left","step0":"No replies yet. Eight equally likely numbers require 3 bits of information to identify one.","step1":"Question: greater than 4? Yes. Remove 1–4. Eight candidates become four: 1 bit gained.","step2":"Question: greater than 6? Yes. Given the first reply, four candidates become two: another 1 bit.","step3":"Question: greater than 7? No. Only 7 remains. Total information: 3 bits; remaining uncertainty: 0.","uncertainty":"Uncertainty left"}}
The information in a reply depends on how much probability mass it eliminates. Here each reply has conditional probability 1/2 at the time it is received, so each contributes 1 bit. The total is log28=3 bits.
This relies on equal probabilities and equal splits. Suppose instead that 7 has probability 0.8, while each other number has probability 0.2/7. Asking “Is it 7?” first lets most cases finish immediately. “Yes” and “no” now carry approximately 0.322 and 2.322 bits respectively. A yes-or-no question does not imply that every reply carries exactly 1 bit.
Self-information: how much does confirming an event tell us?
For an outcome x with probability p(x)>0, its self-information is:
I(x)=−log2p(x)
The rarer the event, the more information confirming it provides. An event with probability 1 has zero self-information: the model already determines its outcome.
Probability in the model
Self-information
Interpretation
1/2
1 bit
Resolve two equally likely alternatives
1/8
3 bits
Identify one of eight equally likely candidates
1/100
About 6.644 bits
A rarer event provides more information
1
0 bits
The outcome is already certain
Why a logarithm? Independent event probabilities multiply, while we want their information to add:
I(x,y)=−log2[p(x)p(y)]=I(x)+I(y)
Without independence, information still adds, but the second term must use the conditional probability:
−log2p(x,y)=−log2p(x)−log2p(y∣x)
Self-information can be fractional. This does not mean we literally asked 0.322 questions, or that a standalone binary codeword can have a fractional length. We will distinguish these quantities below.
Entropy: weight each outcome’s information by its probability
Self-information describes one outcome. Entropy describes the distribution: it is expected self-information.
H(X)=E[I(X)]=−x∑p(x)log2p(x)
Imagine repeatedly drawing independent samples from the same distribution. Common outcomes enter the average more often. Rare outcomes may carry more information individually, but occur less often. We must therefore multiply each information value by its probability before summing.
Consider two outcomes with P(A)=p and P(B)=1−p. Their entropy is the binary entropy function:
h2(p)=−plog2p−(1−p)log2(1−p)
First, look across the full probability range: the horizontal coordinate is p, and the vertical coordinate is the sum of the two contributions, h2(p).
At either endpoint the outcome is certain and entropy is zero. An even split is hardest to predict and gives 1 bit. The curve is symmetric because renaming the outcomes cannot change uncertainty.
Next, unpack one point on this curve. Change the probability and inspect each rectangle’s width, height, and area to see how the two contributions add up.
Preparing the visual
Rarer means taller—and narrower
Drag the probability of A. The blue and gold rectangles change together: width is probability, height is self-information, and area is the contribution to entropy. Adding both areas gives the average information.
{"id":"entropy-probability","title":"Rarer means taller—and narrower","summary":"Drag the probability of A. The blue and gold rectangles change together: width is probability, height is self-information, and area is the contribution to entropy. Adding both areas gives the average information.","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":"Width × height = probability × information = contribution","chartLabel":"Probability and information area diagram. Blue is A; gold is B. Width is probability, height is self-information, and area contributes to entropy.","contribution":"Area · p × I","detailLabel":"See individual terms and model conventions","endpoint":"With a certain outcome, its height is 0. The impossible outcome has width 0 and formally infinite self-information; its contribution is defined as 0 by a limit. Both areas, and entropy, are 0.","eyebrow":"02 / SEE THE WEIGHTED AVERAGE","heading":"How can a rare event carry more information, yet the average be low?","heightMeaning":"Height = self-information I · bits","intro":"Change only the probability of A. Follow each color: its width, its height, and the area they make together.","middle":"Both outcomes are equally likely. Each rectangle is 0.5 wide and 1 bit tall, contributing 0.5 bits. Together they give 1 bit: the maximum binary entropy.","modelNote":"Values are calculated directly from the distribution, without sampling noise. The main height scale is fixed at 0–7 bits; the total contribution bar uses a fixed 1-bit scale.","offcenter":"A less likely outcome makes a taller but narrower rectangle. Area depends on both dimensions, so more information in one event does not necessarily mean a higher average.","probability":"Probability of A","totalLabel":"The sum of both entropy contributions, on a fixed 1-bit scale.","totalMeaning":"Add both areas to get entropy","widthMeaning":"Width = probability p"}}
At p=0.5, each outcome has 1 bit of self-information and contributes 0.5 bits after weighting. Entropy is maximal at 1 bit. Moving toward either endpoint makes the rare outcome more surprising, while lowering average uncertainty. At p=0 or 1, the outcome is certain and entropy is zero.
The convention 0log20=0 follows from limp→0+plog2p=0. A zero-probability event never happens within the model. If it occurs in reality, reconsider the model instead of treating it as an ordinary finite-information observation.
Entropy is not the actual number of questions
Self-information and entropy can be fractional, while an actual yes/no question counts as one question. Optimal symbol-by-symbol prefix coding satisfies H(X)≤L∗<H(X)+1 for at least two positive-probability outcomes. Self-information, entropy, average code length, and worst-case question count are different quantities.
Keep that distinction here. The fair-die decision tree, rounding overhead, and block coding belong in Source Coding and Compression.
Joint entropy, conditional entropy, and mutual information
With two variables, ask: after seeing a clue, how much is still unknown? To expose the averaging, use a nonuniform Y: P(Y=1)=0.1 and P(Y=0)=0.9. The clue is X=Y⊕N, with independent noise flipping the value with probability q.
Initially q=0.1. Observing X=1 can mean that rare Y=1 survived, or that common Y=0 flipped. Both joint probabilities are 0.09, so this branch becomes evenly split. What happens in the other branch, and how should we average them?
Preparing the visual
Different branches: how does conditional entropy average?
Split the joint probabilities by X and normalize each row. Weight each branch entropy by its probability to obtain conditional entropy. One branch can increase uncertainty while the average decreases.
{"id":"entropy-conditioning","title":"Different branches: how does conditional entropy average?","summary":"Split the joint probabilities by X and normalize each row. Weight each branch entropy by its probability to obtain conditional entropy. One branch can increase uncertainty while the average decreases.","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":"Uniform prior","contributions":"On a fixed 0–1-bit scale, segment widths are P(X=x)H(Y|X=x); their sum is conditional entropy.","copy":"Identical","eyebrow":"03 / ONE CLUE AND ALL CLUES","heading":"Different branches: how does conditional entropy average?","independent":"Independent","intro":"Start with the prior on Y, then retain both X branches. Blue/gold encode Y=0/1 above; the contribution strip below separately uses them for X=0/1.","inverted":"Inverted","jointNote":"The four cells are joint probabilities; the right column contains row sums. Normalize each row by its own sum to obtain the conditional distributions below.","more":"More uncertain than the prior","noise":"Independent flip probability q","note":"Each contribution is branch probability × branch entropy on a fixed 0–1-bit scale. Gold outlines mark branches more uncertain than the prior. Mutual information compares the prior with the average over every branch.","priorLabel":"Prior on Y","skewed":"Skewed prior"}}
Conditional entropy: weight every clue by its probability
Divide each table row by its own sum to get P(Y∣X=x), the distribution after one particular observation. Conditional entropy averages the branch entropies using the probabilities of those observations:
H(Y∣X)=x∑P(X=x)H(Y∣X=x).
Initially X=1 occurs with probability 0.18 and has 1-bit entropy. X=0 occurs with probability 0.82 and has about 0.095 bits. Their weighted mean is about 0.258 bits. Neither an unweighted average nor a single branch gives this answer.
Switch to a uniform prior and the rows become symmetric: both branch entropies are h2(q). Computing just one row happens to give the correct average in that special case, but not in general.
Joint entropy: determine the clue, then the original value
Treat (X,Y) as one outcome, with entropy H(X,Y)=−∑x,yp(x,y)log2p(x,y). Alternatively, determine X first, then determine Y within its branch. This gives the chain rule:
H(X,Y)=H(X)+H(Y∣X).
The row sums on the right form P(X) and determine the first term. The weighted branch entropies determine the second. These are the two contributions shown in the joint-entropy readout.
Algebraically, start with p(x,y)=p(x)p(y∣x), take negative logarithms, then average over the joint law. When the variables are independent, H(Y∣X)=H(Y), and joint entropy equals the sum of marginal entropies.
Mutual information: how much uncertainty disappears on average?
Before observing the clue, uncertainty is H(Y). Afterwards, the average remainder is H(Y∣X). Their difference is mutual information:
I(X;Y)=H(Y)−H(Y∣X)=H(X)+H(Y)−H(X,Y).
Initially the prior has about 0.469 bits, and the conditional average is about 0.258 bits, giving 0.211 bits of mutual information. Although one observation can raise uncertainty to 1 bit, averaging over all clues still reduces it.
Mutual information is symmetric, nonnegative, and zero exactly when the variables are independent. Thus H(Y∣X)≤H(Y), without requiring every individual branch to obey that same inequality.
At q=0.5, the clue is independent and mutual information is zero. At q=0 or 1, it determines the original value completely and mutual information equals H(Y). Opposite values can convey complete information. Statistical dependence requires neither identical values nor a causal relation.
Compare the information measures in one diagram
For the two finite discrete variables considered here, a Venn diagram helps organize the identities: the circles represent H(X) and H(Y), their overlap represents I(X;Y), and their union represents H(X,Y). Areas are schematic; they do not show the numerical values for a particular noise setting above.
The left circle gives H(X)=H(X∣Y)+I(X;Y). Adding the three non-overlapping regions gives the joint entropy. The diagram puts these relationships together for reference.
Put the measures side by side
Measure
Object
Question
I(x)
One observed outcome
How much information does confirming it provide?
H(X)
One variable’s distribution
How much uncertainty is there on average?
H(X,Y)
A joint distribution
How uncertain is the pair?
H(Y∣X)
Conditional distributions, averaged over clues
How much remains after learning X?
I(X;Y)
Dependence between variables
How much does learning X remove on average?
Two useful bounds for finite discrete variables are:
H(X)≥0, with equality only for a certain outcome.
For an alphabet of size m, H(X)≤log2m, with equality only when those m outcomes are equally likely.
Alphabet size constrains maximum entropy; the probability distribution determines actual entropy. For sequences, context also matters. Individual letter frequencies and the distribution of the next letter given preceding text are different objects. Their difference cannot be attributed entirely to unequal letter frequencies.
The foundation ends here; explore further when needed
The table is enough preparation for the next chapter. Sequence chain rules and entropy rates appear in Chapter 3. Densities, differential entropy, and coordinate scaling are introduced with Gaussian channels in Chapter 4.
For why conditions change dependence and what processing discards, read Optional: Conditional Information and Data Processing. Conditional groups and merged states explain these separately, without making them prerequisites for the main sequence.
Next: what does an inaccurate predictive distribution cost?
So far we have calculated information using the given distribution itself. Next we distinguish the true data distribution p from the distribution q used to predict or encode it, introducing Cross-Entropy and KL Divergence.
Thomas M. Cover and Joy A. Thomas, Elements of Information Theory, 2nd edition: Chapter 2 on information measures and data processing; Chapter 5 on lossless coding; Chapter 8 on differential entropy.