Comparator composition Created 2026-10-25 Updated 2026-10-31
To combine more and less significant digital comparators, compute and use the displayed formulas. Unequal upper blocks decide the order, because their difference outweighs every possible lower-block difference; equal upper blocks delegate the decision to the lower block. This is an associative operation on the three comparison outcomes. A balanced binary tree of these combinations has circuit size and circuit depth for -bit inputs.
Computer memory 2026-10-13
Storage holding information used by a computer. Here, resident memory pages occupy main computer memory; a physical address identifies a location in the physical address system rather than an operating-system process's private numbering.
Conditional entropy Created 2026-09-24 Updated 2026-10-14
For finite discrete random variables, conditional entropy is the average remaining information entropy of after the value of is known:
Each observation changes the probability distribution used to describe ; the average weights that uncertainty by how often the observation occurs. An observation can increase uncertainty for one particular outcome, even though conditioning reduces entropy on average for finite variables.
For example, let choose with probabilities , and let report whether . If it reports yes, there is no remaining uncertainty. Otherwise the conditional probabilities are , whose information entropy is bits. The two reports each occur with probability , so of a bit. The original uncertainty was bits: this observation removes exactly one bit on average.
If is a function of , then : the observation determines the answer. If and are independent random variables, then : the observation gives no improvement. These endpoints make conditional entropy useful for separating relevant observations from irrelevant ones. They also lead to the chain rule for information entropy, , which counts the first uncertainty and the remaining uncertainty without double counting.
Conditional expectation choice invariant Created 2026-10-18 Updated 2026-10-31
Let be a real-valued objective function of finitely many choices, with finite expected value. Suppose a prefix has positive probability. Write . If the next choice is a fair bit, the law of total expectation gives
At least one child is at least this average. Choose a child with the larger value, using a fixed rule for ties. The resulting loop invariant is . At a complete assignment , there is only one completion left, so and therefore .
For a biased choice or more than two possibilities, use the corresponding weighted average:
Some positive-probability child is at least the weighted average. For minimization, choose a child at most the current conditional expectation and reverse the invariant. The averaging identity is the same in both directions.[ref]
The word "probabilities" in the method's name also covers an indicator random variable for an undesirable outcome: keeping its conditional expectation, which is its conditional probability, strictly below one eventually forces that indicator to be zero. Optimizing an ordinary numerical objective function is the method of conditional expectations formulation used below.
For any partial assignment , let count edges whose two endpoints are already fixed on opposite sides, and let count edges with at least one unassigned endpoint. Under the remaining independent fair bits,
An edge with fixed equal labels contributes zero; fixed unequal labels contribute one. If one endpoint is unassigned, its fair bit disagrees with the fixed label with probability . If both endpoints are unassigned, their independent fair bits disagree with probability as well. Count each unresolved edge once, even when both endpoints are unassigned.
Process vertices in a fixed order. Evaluate the conditional expectation cut formula after setting the next label to zero and after setting it to one; retain the larger value, choosing zero on ties. The conditional expectation choice invariant ensures the final cut of a graph has size at least . This is a deterministic approximation algorithm for maximum cut.[ref]
Directly scanning all edges to evaluate each child of each of choices takes elementary operations, in Big O notation. There is a faster implementation. When assigning vertex , let and count its already assigned graph neighbours labelled zero and one. Contributions from edges not incident to are unchanged, and contributions from edges to unassigned graph neighbours stay for either choice. Therefore
Choose zero if , otherwise one: put on the side with fewer already assigned graph neighbours. With adjacency lists, scanning each vertex's list once costs operations overall and uses storage including the graph. These bounds count operations on labels and counters that fit in machine words of bits. Multiplying the conditional expectation cut formula by two also permits exact integer comparisons without rounding.
If is the size of a maximum cut, then . The constructed cut of a graph thus has size at least , an approximation ratio of in the maximization convention. The five-versus-six example illustrates the gap between this guarantee and exact optimization.
For a general randomized algorithm, the averaging proof alone does not establish efficient derandomization. One needs a polynomial number of commitments, an efficient way to find a suitable child at each step, and manageable representations and evaluation costs for the relevant conditional expectations. Those evaluations can themselves be hard. Enumerating all completions verifies this small example, but would take exponentially many assignments as grows. The polynomial-time algorithm here comes from the local conditional expectation cut formula, not from that enumeration.
Consider the following original five-vertex simple graph, where denotes the undirected edge :
Its seven edges give initial expected value . Use vertex order and choose zero whenever the two child conditional expectations tie.
Figure 1.
A guaranteed five-edge cut and a six-edge maximum cut of the same graph
. The conditional expectations cut example uses the same original simple graph in both panels. Node colours and labels identify the two sides of each cut of a graph. Solid teal edges cross; dashed grey edges do not. The deterministic choices on the left give five crossing edges; the assignment on the right gives six. Crossings of drawn lines are not additional vertices. Details.
The complete decision ledger is below. A prefix lists fixed labels in vertex order; all later labels remain hypothetically independent fair bits. Each candidate entry is the conditional expectation of the final cut of a graph, including the contribution of unresolved edges.
Prefix before choiceNext vertexSet to 0Set to 1Chosen labelRetained conditional expectation
Empty
For example, after , edge is fixed crossing and the other six edges are unresolved, giving . Setting fixes crossing and noncrossing, leaving four unresolved edges: . Setting instead fixes crossing and noncrossing, giving the same conditional expectation.
Figure 2.
Conditional expected cut values along every chosen branch
. At each step, both candidate values are computed by the conditional expectation cut formula. The highlighted cell is chosen; ties choose zero. Below, the retained conditional expectation follows , starting before any label is fixed. The last value is the actual size of the resulting cut of a graph, rather than an average over remaining choices. Details.
The final labels are , so the two sides are and . The five crossing edges are ; do not cross. This exceeds , and hence also the rounded-up guarantee of four edges.
It is not a maximum cut. Labels cross all edges except , giving six. Seven are impossible because the triangle in a graph cannot have all three edges crossing a two-sided cut of a graph. An independent enumeration of all complete label assignments gives the following distribution, counting an assignment and its label-swapped counterpart separately:
Size of cut of a graphNumber of label assignments
The weighted sum is , so the average is , agreeing with linearity of expectation. Choosing in the earlier tie discards the remaining size-six completion while preserving the average of four. The method protects an expected value guarantee; it need not preserve the best possible completion.
Let be a finite undirected simple graph, with vertices and edges. A cut of a graph assigns each vertex a label zero or one; an edge crosses precisely when its endpoints have different labels. Its size is the number of crossing edges. A maximum cut maximizes that size.
For the analysis, assign independent fair bits to the vertices. For each edge , the indicator random variable has expected value : exactly two of the four equally likely endpoint assignments cross. Thus linearity of expectation gives the random cut lower bound:
Linearity of expectation does not require the indicator random variables to be independent. What matters here is the stipulated distribution of the endpoint bits.
Conditional mutual information Created 2026-09-24 Updated 2026-10-14
For finite discrete random variables, conditional mutual information measures the average reduction in uncertainty about from observing , when is already known. With base-two logarithms, it is measured in bits:
The second expression follows from the chain rule for conditional entropy and makes the symmetry in visible. Equivalently, compute the mutual information separately in each conditional probability distribution and then average:
Here is the Kullback-Leibler divergence, also computed with base-two logarithms; zero-probability terms contribute zero. The Gibbs inequality gives , with equality exactly when and have conditional independence given : the conditional joint probability mass function factors for every of positive probability.[ref]
For a fully computed example, take independent random variables that are fair bits, and let , where is exclusive or. The complete joint probability distribution has only these four positive entries:
Table 1.
Joint probabilities for two independent fair bits and their exclusive or
.
Every pair has probability , so . But . Given , the pairs each have conditional probability , while both conditional marginals are fair. Thus
Given , the pairs give the same calculation. Therefore
The conditional entropy calculation tells the same story: because either value of leaves fair, whereas because . Learning the exclusive or does not reveal either bit alone; it reveals whether they agree, so learning one then determines the other.
Figure 1.
Conditioning on the exclusive or reveals one bit of dependence between independent fair bits
. Details.
This example distinguishes conditional independence from ordinary independence. It also disproves the claim that conditioning always reduces mutual information, despite conditioning reduces entropy. There is no general ordering between and : the example above increases it from zero to one, while taking and for a fair bit decreases it from one to zero. The chain rule for mutual information explains why both are possible.[ref]
Conditional mutual information is useful for asking whether an additional observation tells us anything after information already available has been accounted for. Its zero case expresses conditional independence exactly; in a Markov chain, this is the step that turns the chain rule for mutual information into the data processing inequality.
Return to pairwise independence does not imply joint independence, where are independent fair bits and is their exclusive or. Given , only and remain, each with conditional probability . Given , only and remain, again each with conditional probability . Consequently,
The conditional marginal distributions are still fair, so their product has four entries in either case. The actual tables differ: given , and given . Thus unconditional independence need not survive conditioning. Observing whether two bits agree restricts their possible combinations; no physical interaction between the original trials is required to produce that information constraint.
Conditioning reduces entropy Created 2026-09-24 Updated 2026-10-14
For finite discrete random variables , knowing reduces the information entropy of on average:
Equality holds exactly when and are independent random variables. The average over observations is essential: can exceed for a particular . All logarithms here have base two, giving bits, and zero-probability terms contribute zero.[ref]
For Bayesian inference, this compares a prior distribution with the posterior distributions produced by possible observations. An unexpected report can make previously unlikely alternatives plausible, while useful reports reduce uncertainty overall. For lossless source coding, an observation shared by encoder and decoder lets them choose descriptions for the appropriate conditional distribution; sending that observation also has a cost. The example below makes both the saving and that cost explicit.
In A Mathematical Theory of Communication by Claude Shannon (1948), the definition of conditional entropy is already an average over observations, followed by the inequality and its independence condition in section 6, property 6. The phrase “knowledge reduces uncertainty” must be read with that averaging convention.[ref]
On , measure , assigning bit to eigenvalue . Choose Alice's angles and Bob's angles , with . The Bell state correlation is . Each adjacent disagreement term and the last agreement term therefore has probability . For , their total violates the chained modular Bell inequality bound one, and it tends to zero as . At the value is exactly one.
Let be a fair bit, let be an independent Bernoulli random variable with , and set , where is exclusive or. Thus flips the first bit. This constructs a binary symmetric channel with a fair input, for . The joint probability mass function is
The column sums show that is also a fair bit, whatever is. Both marginal distributions therefore have information entropy one bit. Given , only the flip decision remains unknown, giving conditional entropy , where
is the binary entropy, with . The chain rule for information entropy and the definition of mutual information now give
Take . The four joint probabilities, in row order, are . Directly from the definition of joint entropy,
Conditioning on either value of gives probabilities and for the two values of , hence
Adding would overcount by exactly . These are average uncertainties under the stipulated probability distribution; the four possible pairs are still represented by four distinct outcomes.
Figure 1.
A correlated binary pair contains one bit plus the remaining flip uncertainty
. Original exact-model joint probability mass function for . The bars compare the sum of marginal information entropies with the joint entropy from the chain rule for information entropy. The hatched portion is the mutual information counted twice by the marginal sum. Values are calculated, not empirical frequencies. Details.
There is another way to see the decomposition: is a bijection. It merely relabels the four outcomes, so it preserves joint entropy. The independence of and then gives . Describing the initial bit and the flip decision separates shared uncertainty from new uncertainty.
At , the bits are identical: , so and . At , they are complementary: , with exactly the same conditional entropy and mutual information. In either case, observing one determines the other. At , all four joint probabilities are ; the bits are independent, , and . Perfect disagreement is therefore just as informative as perfect agreement.
Figure 2.
Identical and complementary bits both reveal one full bit of information
. Original calculated curves for the constructed pair : joint entropy , conditional entropy , and mutual information , all in bits. The horizontal line marks the one-bit information entropy of either marginal distribution. Reflection about exchanges likely agreement with likely disagreement while preserving these quantities. Details.
For , guessing succeeds with probability , better than guessing . Changing to replaces by and preserves mutual information, since the relabeling is invertible. What matters is how well the observation distinguishes the input, rather than how often its symbol matches the input. The same symmetry makes the binary entropy curve peak at independence, while the mutual information curve reaches its minimum there.
Count leading zeros 2026-10-25
The number of zero bits before the first one, reading a fixed-width binary representation from its most significant bit. The all-zero -bit input has count . Thus , and ; the width is part of the definition.
Cross-entropy 2026-10-14
Cross-entropy measures the average logarithmic loss incurred when outcomes follow one probability distribution , but a model assigns probabilities using another probability distribution . For a finite alphabet, write their probability mass functions as and . With base-two logarithms,
The expectation is under the true or stipulated source law , rather than the model . Terms with contribute nothing. If but for any outcome, the cross-entropy is : the model rules out an event that can occur. The result is measured in bits; natural logarithms give nats.
The useful identity is cross-entropy equals entropy plus relative entropy:
The source's information entropy is the baseline uncertainty. The Kullback-Leibler divergence is the extra average cost of a mismatched model, with the true law first and model second. Thus optimizing for a fixed reduces the mismatch, rather than changing the source's own uncertainty. For finite alphabets, the minimum is , attained exactly at .
Take a three-symbol source with . A matched binary prefix code assigns , , , with lengths . A mismatched prefix code instead assigns , , , with lengths , corresponding to . Both prefix codes decode exactly, but the most common symbol is shorter in the matched code. Under the same source ,
The mismatched code costs an extra (1/4) bit per source symbol on average. No information is lost; the penalty is inefficient representation of this source. The mismatch penalty in lossless coding explains when this coding interpretation is exact.
Figure 1.
Two lossless prefix codes have different average lengths for the same source
. Both sets of codewords are prefix codes. The source probabilities are fixed at . Each colored contribution is source probability times codeword length; changing which symbol receives the shortest word increases the total from to bits per source symbol. Details.
Cross-entropy is also useful when evaluating a predictive distribution. A report that places tiny probability on the realized outcome receives a large logarithmic loss, even when it usually predicts the most common outcome correctly. The loss convention is the negative of the reward convention in the logarithmic scoring rule. Its expected loss is uniquely minimized by the correct probability distribution, making it a strictly proper scoring rule. Strictly Proper Scoring Rules, Prediction, and Estimation by Tilmann Gneiting and others treats this connection in §3.1, Example 3; its discussion uses rewards, so the signs are reversed for the losses here.[ref]
I. J. Good's Rational Decisions by I. J. Good appeared in 1952. Its published summary describes a method for encouraging accurate probability estimates and a connection with information theory. Strictly Proper Scoring Rules, Prediction, and Estimation by Tilmann Gneiting and others traces the logarithmic scoring rule at least as far back as this 1952 paper.[ref]
A discrete memoryless channel on the additive group maps to with probability and to with probability . Every input gives the same conditional entropy , whereas the output Shannon entropy is at most . A uniform input produces a uniform output since every column of the transition matrix sums to one. Hence the channel capacity is bits per use. This cyclic-error channel differs from a channel distributing its error probability equally over both other output symbols.
Data compression 2026-10-13
Data compression represents data using fewer bits than a specified original representation. The saving can reduce storage in a file system and reduce the number of bits sent through a communication channel. At a fixed transmission rate, fewer bits arrive sooner; this makes better use of a fixed transmission budget. Both the encoded data and the instructions needed to interpret them contribute to the size of a stored file.
There are two different promises. Lossless source coding preserves the original exactly: for an encoder and decoder , for every permitted input . Thus must be an injective function. Lossy compression allows to differ from , with the difference judged by an explicit criterion. A program or numerical record may require exact recovery; a preview image may tolerate altered pixels in return for fewer bits.
The appeal of lossless source coding is that repetition can be described rather than copied. Run-length encoding says "repeat this value twelve times"; a prefix code can give more frequent symbols shorter descriptions. These are distinct ways to exploit structure, and neither promises savings for every input. Image compression supplies especially visible examples of both lossless source coding and lossy compression.
Claude E. Shannon's 1948 paper made the role of probability distributions precise. For a memoryless classical information source with Shannon entropy bits per symbol, Shannon's source coding theorem bounds achievable average lengths; sufficiently long blocks allow exact codes to approach bits per symbol. This is a statement about a specified source and average lengths, not a promise to shorten every message.[ref]
For finite discrete random variables, suppose is a Markov chain: the final channel uses only , so and have conditional independence given . In terms of the joint probability mass function,
and hence . Then the two data processing inequalities are
All mutual informations here use base-two logarithms. Thus deterministic or randomized processing cannot increase the information shared with an unprocessed variable.[ref]
For a concrete cascade, take a fair bit and Bernoulli random variables with probabilities , of being one. Assume are jointly independent random variables, and pass through two binary symmetric channels:
The second noise is independent of both and , so this is a Markov chain. Both and are fair bits. The net exclusive or error is one exactly when one noise flips the bit and the other does not:
Using the binary entropy , the three mutual informations are fully determined:
All numbers are in bits. The two losses are and . Thus the cascade retains less information about the original source than either individual channel shares between its own input and output.
Figure 1.
Two noisy binary channels compose to a noisier channel and obey both data processing bounds
. Details.
With fixed and , the effective error is . At , and ; at , is independent of the previous variables and . The diagram plots these endpoints and the computed example.
The data processing inequality is useful for testing what a proposed decoder or data summary could possibly reveal: if its only input is , even randomized processing cannot provide more mutual information about than already contains. The Markov chain hypothesis matters. In the exclusive or example from conditional mutual information, allowing a processor to use both and reveals exactly; that processor has additional input, so the conclusion for processing alone does not apply.
The chain rule for mutual information proves both inequalities and identifies their exact gaps. First expand the information about in the two observation orders:
Therefore . Next use as the variable being learned:
Symmetry of mutual information gives . Both signs follow from the nonnegativity of conditional mutual information; the first gap also gives equality in data processing inequality.
Debounced toggle switch 2026-10-25
A sampled toggle controller can reject short disturbances by requiring three consecutive high samples to toggle, and then three consecutive low samples before another high run is allowed to toggle. One four-bit synchronous sequential circuit stores output , an armed bit , and input history . Initially . Set
The two three-sample run detectors cannot assert simultaneously. A high run toggles once and clears ; only a complete low run rearms it. All right-hand sides use the old state, so the toggling event occurs at the third qualifying clock edge.
The controller has twelve distinguishable behaviours: for each , three armed states count trailing highs of lengths , and three disarmed states count trailing lows of lengths . The run lengths are distinguished by the number of further matching samples needed before a toggle or rearm. Armed and disarmed states are distinguished by an all-high continuation. Thus at least state bits are required, and the displayed design attains that bound.
Decision tree Created 2026-09-24 Updated 2026-10-14
A decision tree represents a deterministic computation of a known Boolean function by inspecting input bits. Each internal vertex of its binary tree names a coordinate to query, its two outgoing edges carry answers 0 and 1, and each leaf carries the output 0 or 1. Starting at the root of a tree, read the named bit, follow its answer edge, and repeat until a leaf is reached. Correctness requires the leaf's label to equal for every input .[ref]
The next coordinate, or the decision to stop, can depend on earlier answers: this is adaptive querying. The same input always follows the same graph path; adaptivity does not require randomness. A correct leaf must have the same output for every completion of the observed bits. Thus a decision tree can stop as soon as the observations form a query certificate. Querying an already known coordinate adds no information, so we use decision trees without repeated coordinates on a graph path; an efficient tree also removes queries made after the output is already forced.
The motivation is exact computation with shortcuts. If inspecting an input entry is expensive, the question is how much of the input must actually be read. The decision-tree query cost counts these inspections, while local calculations on known values are free in this model; this cost need not equal an implementation's time complexity. Here the Boolean function is specified in advance and must be computed exactly on every input. Decision tree learning instead fits a predictor from data, with a different objective.