Two flips in three bits defeat a majority vote. This chapter builds the probability behind that sentence, from events and the binomial distribution to the Gaussian tail, the union bound and the Chernoff bound.
The previous chapter, Why Codes Exist, computed every error probability with two moves, multiplying the chances of bit flips that have nothing to do with each other and adding the chances of error patterns that cannot happen together. Those moves gave the decoded error of the repetition code, 3p2−2p3, and the miss rate of a parity check, because every situation was small enough to list. A 72-bit memory word has 272 possible error patterns and a frame of a thousand bits has 21000, and no list reaches that far.
This chapter turns the two moves into a toolkit that scales. It starts with events on three bits, where every probability can be checked by hand, then counts errors with the binomial distribution, summarizes a count by its expectation and variance, and proves the law of large numbers, which explains why a measured bit error rate settles down to the true one. The Gaussian distribution enters as the model of noise on a voltage, with the Q-function as its tail. The chapter closes with the union bound and the Chernoff bound, the two inequalities the rest of the book leans on whenever an exact sum is out of reach.
Every theorem is proved, after a number that can be checked by hand. The algebra needed is powers, the exponential function and the natural logarithm, and the Gaussian section explains the one idea from calculus it uses, the integral as an area. Every number in the chapter is recomputed by ch02_probability_for_coding.py, in the python/ folder of the companion repository ecc-book-lab, which prints each value beside the one the text states and stops at the first disagreement. The charts are drawn by ch02_charts.py in the same folder.
Send the codeword 000 of the three-bit repetition code over the binary symmetric channel of the previous chapter, BSC(0.1), which flips each bit with probability p=0.1 and leaves it alone with probability 0.9. The receiver sees one of eight patterns. A pattern with w flipped bits has probability 0.1w0.93−w, so the received word 000 has probability 0.93=0.729, each of 100, 010 and 001 has probability 0.1×0.92=0.081, each of 110, 101 and 011 has probability 0.12×0.9=0.009, and 111 has probability 0.13=0.001. The eight numbers add to 1, as they must, because some pattern always arrives.
That list is the whole experiment. Any question about one use of the channel, such as whether the decoder will fail, is answered by adding the probabilities of the patterns where the answer is yes. The vocabulary below names the pieces, so that the same reasoning reaches lists too long to write down.
The set of every possible outcome is the sample space, written Ω, the capital Greek letter omega. Here Ω holds the eight received patterns. A single outcome is written ω, the lower-case omega, and the statement "ω belongs to the set E" is written ω∈E. An event is any set of outcomes, the set for which some yes-or-no question has the answer yes.
Three facts follow at once. The whole sample space has probability P(Ω)=1, the empty event has probability 0, and two events E and F that share no outcome, called disjoint, satisfy P(E∪F)=P(E)+P(F), where E∪F, the union, is the set of outcomes in E or F or both. The last fact holds because each outcome of the union appears in exactly one of the two sums.
Two events on the three bits carry the rest of this section. Event A is "the first bit flipped," the set {100,110,101,111}, with probability 0.081+0.009+0.009+0.001=0.1, which had to equal p and so checks the list. Event B is "the majority decoder fails," which happens when two or more bits flip, the set {110,101,011,111}, with probability 3×0.009+0.001=0.028, the decoded error of R3 found in the previous chapter. Figure 1 shows both events.
Figure 1. The eight outcomes of sending 000 through BSC(0.1), in rows by the number of flips. Event A, the first bit flipped, has probability 0.1, event B, the decoder fails, has probability 0.028, and the three outcomes they share carry 0.019.
The complement of an event B, written Bc and read "not B," is the set of outcomes outside B, here the event that the decoder succeeds. Since B and Bc are disjoint and together make up Ω, P(Bc)=1−P(B)=0.972. The complement is often the easier side of a question, which is how the previous chapter found the chance of at least one error in a terabyte.
The intersectionA∩B is the set of outcomes in both events. Here it is {110,101,111}, the cases where the first bit flipped and the decoder failed, with probability 0.009+0.009+0.001=0.019. The union A∪B is {100,110,101,111,011}, with probability 0.081+0.009+0.009+0.001+0.009=0.109. Adding P(A)+P(B)=0.128 gives too much, because the three shared outcomes were counted once in each event.
Proof. The union splits into three disjoint pieces, the outcomes in A only, written A∩Bc, the outcomes in both, A∩B, and the outcomes in B only, Ac∩B. Additivity gives P(A∪B)=P(A∩Bc)+P(A∩B)+P(Ac∩B). The event A splits the same way into A∩Bc and A∩B, so P(A)=P(A∩Bc)+P(A∩B), and likewise P(B)=P(Ac∩B)+P(A∩B). Adding the last two equations gives P(A)+P(B)=P(A∪B)+P(A∩B), which rearranges to the theorem. ■
The check on the example is 0.1+0.028−0.019=0.109, which matches the direct sum.
Suppose a test reveals that the first bit flipped, and nothing about the other two. The outcomes still possible are those of A, totaling 0.1, and the failing ones among them total 0.019. Rescaling the survivors so that they add to 1 gives a failure probability of 0.019/0.1=0.19. Direct reasoning agrees, since the decoder now fails unless both other bits arrive intact, so failure has probability 1−0.92=0.19, up from 0.028.
The opposite case, where the test shows that the first bit arrived intact, gives P(B∣Ac)=P(Ac∩B)/P(Ac). The only failing pattern with an intact first bit is 011, so this is 0.009/0.9=0.01, which is p2, the chance that both remaining bits flip.
The two conditional probabilities rebuild the unconditional one. Weighting each by the probability of its condition gives 0.19×0.1+0.01×0.9=0.028, which is P(B) again.
Proof. Every outcome of B lies in exactly one Ai, so B is the disjoint union of the pieces B∩A1,…,B∩Am, and additivity gives P(B)=∑iP(B∩Ai). The definition of conditional probability, multiplied through by P(Ai), says P(B∩Ai)=P(B∣Ai)P(Ai). Substituting each term gives the theorem. ■
Now reverse the question. Given that the decoder failed, how likely is it that the first bit flipped? The definition gives P(A∣B)=P(A∩B)/P(B)=0.019/0.028=19/28=0.6786, up from 0.1, because a failure needs at least two flips, and two of the three two-flip patterns, as well as 111, involve the first bit.
Proof. The definition of conditional probability, applied in both directions, gives P(A∣B)P(B)=P(A∩B) and P(B∣A)P(A)=P(A∩B). The two left-hand sides are therefore equal, and dividing by P(B) gives the theorem. ■
Bayes' rule is the step every decoder takes, because a channel gives the probability of what is received given what was sent, while a receiver needs the reverse.
In the reversal above, learning B changed the probability of A. Events for which the knowledge changes nothing are the ones the channel model is built from.
The events A and B fail the test, since P(A)P(B)=0.1×0.028=0.0028 while P(A∩B)=0.019. The event C, "the second bit flipped," passes it, since A∩C={110,111} has probability 0.009+0.001=0.01=P(A)P(C). Flips of different bits are independent, as the channel promises.
For more than two events the definition needs a stronger form. Events E1,…,En are mutually independent when, for every choice of some of them, the probability that all the chosen events occur is the product of their probabilities. The binary symmetric channel assumes this of the events Fi, "bit i flipped," each of probability p, and that is where the pattern probability of 110 comes from. The event "110 received" is what remains of F1∩F2 after removing F1∩F2∩F3, so
Mutual independence is genuinely stronger than independence of every pair. At p=1/2, take F1, F2 and the event G that bits 1 and 2 agree. Each has probability 1/2 and every pair intersects with probability 1/4, so the three are independent in pairs. Yet all three occur exactly when bits 1 and 2 both flip, with probability 1/4, not the product 1/8.
A decoder usually asks how many bits flipped. A random variable is a rule that assigns a number to every outcome. Let X be the number of flipped bits among the three, so X(000)=0, X(100)=1 and X(110)=2. The event X=2 is the set {110,101,011}, with probability 3×0.009=0.027, and the four values give P(X=0)=0.729, P(X=1)=0.243, P(X=2)=0.027 and P(X=3)=0.001, the last column of the table in the previous chapter.
The formula below does the same job for any number of bits. It uses the factorial n!, the product 1×2×⋯×n, with 0!=1 by convention, and the binomial coefficient (kn), read "n choose k," which counts the ways to choose k positions out of n.
Proof. First the count. Choose the k flipped positions one at a time. There are n choices for the first, n−1 for the second, and so on down to n−k+1 for the last, so there are n(n−1)⋯(n−k+1)=n!/(n−k)! ordered choices. Each set of k positions is reached in k! of these orders, by the same count applied to its own k positions, so there are n!/(k!(n−k)!) distinct sets.
Next one pattern. A pattern with flips in a given set of k positions is the intersection of k events "bit i flipped" and n−k events "bit i did not flip." By mutual independence its probability is the product pk(1−p)n−k, the same for every such pattern.
Finally the sum. The event X=k is the disjoint union of the (kn) patterns with exactly k flips, so additivity gives (kn) times the common pattern probability. To see that the probabilities add to 1, expand (x+y)n as a product of n factors (x+y). Each term of the expansion picks x from some of the factors and y from the rest, and the terms that pick x from exactly k factors number (kn), which proves the binomial theorem (x+y)n=∑k(kn)xkyn−k. Setting x=p and y=1−p gives ∑kP(X=k)=(p+1−p)n=1. ■
For n=3 and p=0.1 the formula gives (23)0.120.9=3×0.009=0.027, as the list did. Table 1 applies it to a byte on a channel with p=0.01.
Table 1. The number of flips X in a byte sent through BSC(0.01)
Flips k
Patterns (k8)
P(X=k)
0
1
0.922745
1
8
0.074565
2
28
0.0026361
3
56
5.3255×10−5
4
70
6.7242×10−7
5 or more
93
5.4612×10−9
Source: computed from the binomial distribution and reproduced by ch02_probability_for_coding.py.
The table explains two numbers from the previous chapter. A byte holds at least one error with probability 1−0.922745=0.077255, which is 1−0.998, and almost all of the parity check's miss rate, 0.0026368, is the row k=2, at 0.0026361. Each row is a small correction to the one above it, which is why a code that handles the few most likely error counts handles nearly everything.
Figure 2 plots the distribution for a 20-bit block on a poor channel, p=0.1. The bars rise from P(X=0)=0.1216 to a peak of 0.2852 at k=2 and then fall, through 0.1901, 0.0898 and 0.0319, down to 0.0004 at k=8.
Figure 2. The number of flips in 20 bits through BSC(0.1). The most likely count is 2, which is also the mean np, and five or more flips together have probability 0.0432. Data: computed from the binomial distribution by ch02_charts.py in the companion repository.
The peak is located without computing every bar. Dividing two neighboring values of Equation 4 cancels most of the factorials,
because (k+1n)/(kn)=(k+1)!(n−k−1)!k!(n−k)!=k+1n−k. With n=20 and p/(1−p)=1/9, the ratio is 20/9=2.22 at k=0, 19/18=1.06 at k=1 and 18/27=0.667 at k=2, and it keeps shrinking as k grows. The bars grow while the ratio exceeds 1, so the peak is at k=2. For coding the tail matters more, since a code that corrects any four errors in this block fails with probability P(X≥5)=0.0432.
Two numbers summarize a distribution, where its values sit on average and how far they stray. For the three bits, weighting each count by its probability and adding gives 0×0.729+1×0.243+2×0.027+3×0.001=0.3. Over many uses the flips would average near 0.3, a claim the law of large numbers makes precise, and the answer is 3×0.1, three bits each contributing 0.1 flips on average. That is no coincidence.
The value 3×0.1 comes from splitting the count into pieces. For each bit position i, define the indicatorXi, which is 1 if bit i flipped and 0 if not. The count of flips is the sum of the indicators, X=X1+X2+⋯+Xn, as Figure 3 shows for one received byte. Each indicator has expectation 1×p+0×(1−p)=p. What remains is to show that the expectation of a sum is the sum of the expectations.
Figure 3. Counting flips with indicators. Each position contributes 1 if its bit flipped and 0 if not, so the indicator row adds up to the number of flips, here 2. Since each indicator has mean p, the count has mean 8p.
The proof rests on a second way to compute an expectation, one outcome at a time instead of one value at a time. Each value k collects the outcomes ω with X(ω)=k, so kP(X=k)=∑ω:X(ω)=kX(ω)P(ω), where the sum runs over the outcomes with that value. Adding over all values reaches every outcome exactly once, so
E[X]=ω∈Ω∑X(ω)P(ω).
Proof. By the outcome-by-outcome form, E[X+Y]=∑ω(X(ω)+Y(ω))P(ω)=∑ωX(ω)P(ω)+∑ωY(ω)P(ω)=E[X]+E[Y], by splitting one sum into two. Likewise E[cX]=∑ωcX(ω)P(ω)=c∑ωX(ω)P(ω)=cE[X]. ■
Proof. Write X as the sum of its indicators and apply linearity n−1 times, E[X]=E[X1]+⋯+E[Xn]=p+⋯+p=np. ■
The proof never touched the binomial probabilities, which is the strength of linearity. It justifies the previous chapter's error counts, such as 28.8 errors in an hour of 2.88×1013 bits on a link with p=10−12, even though the count in any given hour could be anything from zero upward.
The mean says nothing about how far a count strays from it. For the three bits, the squared distances of the four possible counts from the mean 0.3 are (0−0.3)2=0.09, (1−0.3)2=0.49, (2−0.3)2=2.89 and (3−0.3)2=7.29. Weighting them by their probabilities gives 0.09×0.729+0.49×0.243+2.89×0.027+7.29×0.001=0.27. Squaring keeps distances above and below the mean from canceling.
For the three bits, σ=0.27=0.5196 flips. A second formula for the variance is usually quicker.
Proof. Expand the square and apply linearity, treating μ as a constant, E[(X−μ)2]=E[X2]−2μE[X]+μ2=E[X2]−2μ2+μ2=E[X2]−μ2. For the second claim, cX has mean cμ, so Var(cX)=E[(cX−cμ)2]=c2E[(X−μ)2]. ■
The check is E[X2]=1×0.243+4×0.027+9×0.001=0.36, and 0.36−0.32=0.27. Means add for any random variables, but variances add only for independent ones. Random variables X and Y are independent when P(X=x and Y=y)=P(X=x)P(Y=y) for every pair of values x and y, as the indicators of different bits on a binary symmetric channel are.
Proof. Group the outcomes by the pair of values (x,y). Then E[XY]=∑x∑yxyP(X=x and Y=y)=∑x∑yxyP(X=x)P(Y=y), and the double sum factors as (∑xxP(X=x))(∑yyP(Y=y))=E[X]E[Y]. ■
Proof. Write μX and μY for the two means. By the lemma on the second moment and linearity,
The last bracket is zero by the product lemma. For n variables, add them one at a time. Under mutual independence the partial sum X1+⋯+Xk is independent of Xk+1, so each new term adds its own variance. ■
Proof. An indicator takes only the values 0 and 1, so Xi2=Xi and E[Xi2]=p. The lemma gives Var(Xi)=p−p2=p(1−p). The indicators are mutually independent, so their variances add to np(1−p). ■
For three bits, 3×0.1×0.9=0.27, matching the direct sum. For the fast link, Table 2 sets each mean beside its standard deviation.
Table 2. Errors on a link at 8×109 bits per second with p=10−12
Span
Bits N
Mean Np
Standard deviation
Standard deviation over mean
One terabyte
8×1012
8
2.828
0.354
One hour
2.88×1013
28.8
5.367
0.186
One day
6.912×1014
691.2
26.29
0.038
Source: computed from the binomial mean and variance and reproduced by ch02_probability_for_coding.py.
The last column falls as the span grows. The standard deviation is close to Np, since 1−p is all but 1, so it grows as the square root of the number of bits while the mean grows in proportion, and their ratio shrinks like 1/Np, from about a third of the mean for a terabyte to under 4% for a day.
A test bench measures a bit error rate by dividing the errors found by the bits sent. Whether that fraction approaches the true p, and how many bits it needs, depends on turning a mean and a variance into a statement about probability, which the next two inequalities do.
Take a frame of 1000 bits on a channel with p=0.01, so the mean number of errors is 1000×0.01=10. Suppose nothing else is known except that the count is never negative. If more than half of all frames carried 20 or more errors, those frames alone would push the average above 21×20=10. So at most half do.
Proof. Split the defining sum of E[X] into the values below a and the values at or above it. The first part is at least zero, because X≥0, and in the second each value is at least a, so
The frame example gives P(X≥20)≤10/20=0.5, more than a hundred times the exact binomial value 0.0032884, because the inequality uses nothing but the mean. The proof has a picture. The step that is 1 for x≥a and 0 below never exceeds the line x/a when x≥0, and averaging both sides over the distribution of X is the proof. Figure 4 draws the step with three curves above it, and the closer a curve hugs the step where the probability sits, the better its bound.
Figure 4. Three functions that lie above the step 1[x≥a], drawn for a=2 and mean μ=1. Markov's line x/a, Chebyshev's parabola ((x−μ)/(a−μ))2 and the Chernoff exponential es(x−a) with s=1 each bound P(X≥a) by their average value. Data: computed by ch02_charts.py in the companion repository.
The variance adds information that the mean lacks, and applying Markov's inequality to the squared distance from the mean puts it to work.
Proof. The random variable Y=(X−μ)2 is never negative and has mean σ2. The event ∣X−μ∣≥d is the same as Y≥d2, so Markov's inequality applied to Y with a=d2 gives P(∣X−μ∣≥d)=P(Y≥d2)≤σ2/d2. ■
For the frame, the variance is 1000×0.01×0.99=9.9. Twenty or more errors means a distance of at least 10 above the mean, so P(X≥20)≤P(∣X−10∣≥10)≤9.9/100=0.099. That is five times better than Markov and still about thirty times the exact 0.0032884.
The real use of Chebyshev's inequality is that it holds for every distribution with that mean and variance. Setting d=kσ shows that no random variable lands k or more standard deviations from its mean with probability above 1/k2. For a day on the fast link, four standard deviations are 4×26.29=105.2 errors, so the day's count lies between 691.2−105.2=586.0 and 691.2+105.2=796.4 except with probability at most 1/16=0.0625, and a count outside that range is strong evidence that the error rate is not 10−12.
Proof. By linearity, E[Xˉn]=n1(nμ)=μ. By the variance of a sum and the rule Var(cX)=c2Var(X), Var(Xˉn)=n21(nσ2)=σ2/n. Chebyshev's inequality with d=ε gives the bound. ■
Here ε, the Greek letter epsilon, is the tolerance. However small it is, a long enough run makes a miss as unlikely as desired. In Figure 5, three simulated runs of a channel with p=0.1 wander over their first few dozen bits and then settle, and by 10,000 bits each sits inside a band of half-width 2p(1−p)/n=0.006 around the true value.
Figure 5. The measured fraction of flipped bits in three simulated runs of BSC(0.1). The band marks two standard deviations of the average, ±2p(1−p)/k, which narrows to ±0.006 at k=10,000. Data: simulated with fixed seeds by ch02_charts.py in the companion repository.
For a bit error rate measurement, let Xi be the indicator that bit i arrived wrong, so μ=p and σ2=p(1−p), and Xˉn is the measured error fraction. Asking for the measurement to land within ε of p except with probability δ, the Greek letter delta, means making the right side of Equation 9 at most δ, which needs
n≥ε2δp(1−p).
To measure p=10−3 to within ε=10−4 with failure probability δ=0.05, Chebyshev asks for n≥0.000999/(10−8×0.05)=1,998,000 bits. The demand is generous, because it holds for any distribution. At n=106 bits the standard deviation of the measured fraction is already p(1−p)/n=3.16×10−5, so the tolerance sits more than three standard deviations away. Sharper statements need the shape of the distribution.
Underneath a bit flip there is usually a voltage. Suppose a transmitter sends a 1 as +1 volt and a 0 as −1 volt, and the wire adds a random noise voltage with mean 0 and standard deviation σ=0.5 volt. The receiver decides 1 when the voltage it sees is above 0 and 0 otherwise. When a 1 is sent, the decision is wrong if the noise falls below −1 volt, more than two standard deviations below its mean. For the noise found in practice that happens with probability Q(2)=0.02275, the shaded area in Figure 6.
Figure 6. Received voltage for a 1 sent as +1 and a 0 sent as −1, with Gaussian noise of standard deviation 0.5. The shaded tail of the +1 curve below the threshold is the probability of a wrong decision, Q(2)=0.0228. Data: computed by ch02_charts.py in the companion repository.
A voltage takes values in a continuous range, so any one exact value has probability zero. Probabilities come instead from a density, a curve f(x)≥0 with total area 1, and the probability of landing between a and b is the area under the curve between them, written ∫abf(x)dx. The symbol ∫, an elongated S for "sum," stands for the limit of adding many thin rectangles of width dx and height f(x). Every earlier rule carries over with sums replaced by areas, so E[X]=∫xf(x)dx, Var(X)=∫(x−μ)2f(x)dx, and linearity holds as before.
The standard curve peaks at ϕ(0)=1/2π=0.3989 and falls off symmetrically, faster than any power of x. The received voltage for a sent 1 in the opening example is N(1,0.25), a copy of the standard curve half as wide and twice as tall.
Proof. Let I=∫−∞∞e−x2/2dx. Its square is a volume over the whole plane, I2=∫∫e−(x2+y2)/2dxdy, and the trick is to compute that volume in rings. The height e−(x2+y2)/2 depends only on the distance r=x2+y2 from the origin. The thin ring between radius r and r+dr has circumference 2πr, width dr and therefore area 2πrdr, so
I2=∫0∞e−r2/22πrdr=2π[−e−r2/2]0∞=2π(0+1)=2π,
where the bracket evaluates an antiderivative at the two ends, checked by differentiating −e−r2/2 to get re−r2/2. So I=2π, and dividing by 2π makes the total area of ϕ equal to 1. The mean ∫xϕ(x)dx is 0, because ϕ(−x)=ϕ(x) and the contributions of x and −x cancel. For the variance, note that differentiating gives ϕ′(x)=−xϕ(x). Integration by parts, which is the product rule for derivatives read backward, ∫uv′dx=[uv]−∫u′vdx, with u=x and v=−ϕ, gives
Every Gaussian is a stretched and shifted standard one. If Z is standard, then X=μ+σZ has mean μ and variance σ2 by linearity and the scaling rule, and substituting x=μ+σz in the area P(X≤t)=∫−∞(t−μ)/σϕ(z)dz turns it into ∫−∞tσ1ϕ((x−μ)/σ)dx, whose integrand is exactly Equation 10. So a question about any Gaussian becomes a question about Z, by measuring distances from the mean in units of σ.
Thermal noise in a receiver is close to Gaussian because it is the sum of the tiny voltages of an enormous number of electrons moving independently. The central limit theorem says that for mutually independent terms with a common distribution of mean μ and variance σ2, the probabilities of (X1+⋯+Xn−nμ)/(σn) approach those of Z as n grows, whatever that distribution is. Its proof needs tools beyond this chapter and is given by Grinstead and Snell [1]. The theorem also makes a binomial count with large n look roughly Gaussian, with limits that the warning at the end of this section examines.
For a Gaussian X with mean μ and standard deviation σ, P(X>μ+xσ)=Q(x), and by the symmetry of ϕ the lower tail is the same, P(X<μ−xσ)=Q(x). In the opening example the noise must fall 1/0.5=2 standard deviations below its mean, so the error probability is Q(2)=0.02275. Table 3 shows the error probability collapsing as the noise shrinks.
Table 3. Decision error for ±1 volt signals as the noise standard deviation shrinks
Noise σ (volts)
Distance to threshold 1/σ
Error probability Q(1/σ)
1
1
0.1587
0.5
2
0.02275
0.4
2.5
0.00621
1/3
3
0.00135
0.25
4
3.167×10−5
0.2
5
2.867×10−7
1/6
6
9.866×10−10
Source: computed from the standard Gaussian and reproduced by ch02_probability_for_coding.py.
Halving the noise from 0.5 to 0.25 volt cuts the error probability by a factor of Q(2)/Q(4)=718. The same steep curve returns whenever coded and uncoded systems are compared later in the book.
The Q-function is not on a calculator's keyboard, so on paper it is bounded, and the bounds below are tight exactly where coding needs them, far out in the tail.
Proof. The upper bound uses t/x>1 for t>x, so Q(x)=∫x∞ϕ(t)dt<∫x∞xtϕ(t)dt. Since −ϕ has derivative tϕ(t), the last integral is x1[−ϕ(t)]x∞=ϕ(x)/x.
The lower bound starts from the derivative of ϕ(t)/t, which is (tϕ′(t)−ϕ(t))/t2=−ϕ(t)(1+1/t2). Integrating from x to infinity gives ∫x∞(1+1/t2)ϕ(t)dt=ϕ(x)/x. For t>x the factor 1+1/t2 is less than 1+1/x2, so ϕ(x)/x<(1+1/x2)Q(x), which rearranges to Q(x)>xϕ(x)/(1+x2).
For the last bound, substitute t=x+u, so that Q(x)=∫0∞ϕ(x+u)du. Expanding the square in the exponent, ϕ(x+u)=ϕ(u)e−x2/2e−xu, and e−xu≤1 for u≥0. Hence Q(x)≤e−x2/2∫0∞ϕ(u)du=21e−x2/2, because half the area of ϕ lies to the right of 0. ■
Table 4. The Q-function and its bounds
x
Lower 1+x2xϕ(x)
Q(x)
Upper xϕ(x)
21e−x2/2
1
1.210×10−1
1.587×10−1
2.420×10−1
3.033×10−1
2
2.160×10−2
2.275×10−2
2.700×10−2
6.767×10−2
3
1.330×10−3
1.350×10−3
1.477×10−3
5.554×10−3
4
3.149×10−5
3.167×10−5
3.346×10−5
1.677×10−4
5
2.859×10−7
2.867×10−7
2.973×10−7
1.863×10−6
6
9.853×10−10
9.866×10−10
1.013×10−9
7.615×10−9
Source: computed from the standard Gaussian and reproduced by ch02_probability_for_coding.py.
Table 4 and Figure 7 show the squeeze. At x=6 the upper bound is only 1.026 times Q, and Q only 1.0013 times the lower bound. The simpler bound 21e−x2/2 is looser by a growing factor, but it shows the essential fall like e−x2/2 with the easiest algebra to carry through a calculation.
Figure 7. The Q-function between its upper bound ϕ(x)/x and lower bound xϕ(x)/(1+x2), which close in as x grows, with the simpler bound 21e−x2/2 above. Data: computed by ch02_charts.py in the companion repository.
The decoder for R3 fails when some pair of bits both flip, which is the union of three events, "bits 1 and 2 flipped," "bits 1 and 3 flipped" and "bits 2 and 3 flipped." Each has probability p2=0.01, so adding them gives 3p2=0.03, against the exact 0.028. As Figure 8 shows, the sum counts the pattern 111 three times where the union counts it once, an excess of 2×0.001=0.002. Adding the probabilities of overlapping events can only overcount.
Figure 8. Adding the three pair events of R3 at p=0.1 counts the pattern 111 three times, giving 0.030 against the union's 0.028. The overcount, 2×0.001, is why the union bound is an upper bound.
Proof. For two events, inclusion–exclusion gives P(A1∪A2)=P(A1)+P(A2)−P(A1∩A2)≤P(A1)+P(A2), since no probability is negative. Suppose the bound holds for m−1 events. Writing the union of m events as the union of two, U=A1∪⋯∪Am−1 and Am, the two-event case gives P(U∪Am)≤P(U)+P(Am), and the assumption bounds P(U) by the sum of the first m−1 probabilities. By induction the bound holds for every m. ■
Proof. At least t flips occur exactly when some set of t positions all flip. For each of the (tn) sets S of t positions, the event "every bit in S flipped" has probability pt by mutual independence, whatever the other bits do. The union bound over all the sets gives the theorem. ■
The bound is excellent when errors are rare, because the overcount comes from outcomes lying in two events at once, which are rarer still. Server memory protects each 64-bit word with an 8-bit check, a 72-bit code that corrects one error and detects two [2]. If each stored bit is upset with probability q=10−6 between checks, independently, the chance of any error is at most 72q=7.2×10−5, against an exact 7.19974×10−5, and the chance of two or more, beyond correction, is at most (272)q2=2.556×10−9, against an exact 2.55588×10−9. The same bound gives the leading term of the previous chapter's R5 formula, since five copies fail with three or more flips, at most (35)p3=10−5 at p=0.01 against an exact 9.8506×10−6.
The bound is worthless when the events are common. For the previous chapter's server with 16 memory modules, each with an 8% chance of an error in a year, it gives 16×0.08=1.28, while the exact value under independence is 1−0.9216=0.7366. The union bound is a tool for rare events, the regime every working code is designed for.
Table 5 puts the tools of this chapter side by side on two tail probabilities, the chance of at least twice the mean number of errors in 1000 bits and in 10,000 bits on a channel with p=0.01.
Table 5. Bounds on twice the mean number of errors, p=0.01
Method
P(X≥20), n=1000
P(X≥200), n=10,000
Markov
0.5
0.5
Chebyshev
0.099
0.0099
Chernoff
0.0200
1.008×10−17
Exact
0.0032884
5.630×10−19
Gaussian approximation
7.41×10−4
4.6×10−24
Source: computed from the binomial distribution and the bounds in this chapter and reproduced by ch02_probability_for_coding.py.
Markov's bound does not improve with length at all, and Chebyshev's improves only in proportion to n. The exact tail falls by a factor of more than 1015 between the two columns, and only the Chernoff bound keeps pace, staying above the truth, as a bound must, by a factor of about 18 at n=10,000. The Gaussian approximation lands below the truth. Figure 9 shows the same contrast across a range of thresholds for the 1000-bit frame.
Figure 9. Bounds on the probability of at least k errors among 1000 bits with p=0.01. Markov and Chebyshev flatten out, while the Chernoff bound falls with the exact tail and stays a little above it. Data: computed by ch02_charts.py in the companion repository.
The idea, due to Chernoff [3], is to apply Markov's inequality to esX for a positive number s chosen afterward, since an exponential separates a tail value from the mean far more sharply than a line or a parabola can. For numbers a and p strictly between 0 and 1, the resulting exponent is the relative entropy of a from p, measured in natural logarithms,
D(a∥p)=alnpa+(1−a)ln1−p1−a.
Proof. For any s>0 the function esx is increasing, so the event X≥an is the same as esX≥esan. Markov's inequality applied to the positive random variable esX gives P(X≥an)≤E[esX]/esan.
Write X=X1+⋯+Xn with indicators. Then esX=esX1⋯esXn, a product of independent factors, so the product lemma, applied one factor at a time, gives E[esX]=∏iE[esXi]. Each factor is E[esXi]=(1−p)e0+pes=1−p+pes. Therefore
P(X≥an)≤((1−p+pes)e−sa)nfor every s>0.
The best s minimizes the logarithm of the bracket, g(s)=ln(1−p+pes)−sa. Setting its derivative pes/(1−p+pes)−a to zero and solving gives es=a(1−p)/(p(1−a)), which exceeds 1 because a>p, so this s is positive. With that choice, 1−p+pes=(1−p)+a(1−p)/(1−a)=(1−p)/(1−a), and the bracket becomes
The bound has teeth because D(a∥p)>0 whenever a>p. At s=0 the function g equals ln1=0 and has slope p−a<0, so g dips below zero for small positive s, and its minimum, −D(a∥p), is negative. The probability that the fraction of flipped bits reaches a therefore falls exponentially in n, at a rate set by how far a is from p.
For the 1000-bit frame with p=0.01 and the threshold a=0.02, the optimal es=0.02×0.99/(0.01×0.98)=2.0204, so s=0.7033, and (1−p)/(1−a)=1.0102. The exponent is D(0.02∥0.01)=0.02ln2+0.98ln(0.98/0.99)=0.0039136, so nD=3.9136 and the bound is e−3.9136=0.0200. That is five times better than Chebyshev at this length, and multiplying the length by ten raises the exponent to 39.136 and the bound to 1.008×10−17.
The majority decoder of Rn, for odd n, fails when more than half the copies flip, which implies X≥n/2. Setting a=1/2 in the Chernoff bound gives an exponent that simplifies neatly,
D(21p)=21ln2p1+21ln2(1−p)1=−21ln(4p(1−p)),
and so
Pe(Rn)≤e−nD(1/2∥p)=(4p(1−p))n/2.
That is the bound the previous chapter proved by a counting argument written for the occasion. At p=0.1, D(21∥0.1)=−ln(0.36)/2=0.5108, and for R25 the bound is 0.3612.5=2.843×10−6, against an exact failure probability of 1.621×10−7. It is about eighteen times too large but has the right exponential rate, and it took one line. The relative entropy returns in Information and Entropy, which builds it from first principles, and in Capacity and Shannon's Theorem.
This chapter treated a channel as a list of flip probabilities. The next chapter, Channels, Signals and Likelihoods, opens the channel up. The binary symmetric channel is joined by the binary erasure channel, in which a bit is either delivered correctly or visibly lost, and the Z-channel, in which only one direction of flip occurs, as when charge leaks out of a memory cell but never in. The voltage example becomes the additive white Gaussian noise channel with binary phase-shift keying, together with signal space, the matched filter and the proof that the receiver built from them makes the fewest errors possible. The signal-to-noise ratio, measured in coding as the energy per bit over the noise density, Eb/N0, replaces the bare σ of Table 3, and comparing hard decisions, which keep only the bit, with soft decisions, which keep the voltage, shows how much a threshold throws away.
Bayes' rule becomes the receiver's main tool. The probability of a received voltage given each possible bit is a likelihood, and the log-likelihood ratio packs everything the receiver knows about one bit into a single signed number. The warning about bursts becomes the Gilbert–Elliott channel, a two-state model that switches between a good state and a bad one, and the chapter closes with the fault models of memory, stuck-at faults, transient upsets and multi-bit upsets, which decide what a memory code must survive. Lin and Costello [4] treat this material at greater length.
[1]Grinstead, Charles M. and Snell, J. Laurie (2006). “Grinstead and Snell's Introduction to Probability.” The CHANCE Project. Version dated 4 July 2006 of the second edition published by the American Mathematical Society, free under the GNU Free Documentation License. https://math.dartmouth.edu/~prob/prob/prob.pdf
[2]Hsiao, M. Y. (1970). “A Class of Optimal Minimum Odd-weight-column SEC-DED Codes.” IBM Journal of Research and Development, 14(4), pp. 395–401. doi:10.1147/rd.144.0395
[3]Chernoff, Herman (1952). “A Measure of Asymptotic Efficiency for Tests of a Hypothesis Based on the Sum of Observations.” The Annals of Mathematical Statistics, 23(4), pp. 493–507. doi:10.1214/aoms/1177729330
[4]Lin, Shu and Costello, Jr., Daniel J. (2004). “Error Control Coding: Fundamentals and Applications.” 2nd edition. Pearson Prentice Hall.
— Anirban
Hardware–software at the seam where compilers meet microcode.