A11 · Lesson 53 · Project
Build a digital link in Python and measure its error rate
Communication engineers judge every modulation and code by one graph: bit error rate against , the energy per bit relative to the noise density. In this project you'll produce that graph yourself. You'll write a noise channel calibrated in , send random bits through it, measure the error rate at several noise levels, and check the result against the Q-function formula. Then you'll test an obvious idea for doing better, sending every bit three times and taking a vote, and find out why it doesn't work the way you'd expect.
- The solid curve is the bit error rate of plain antipodal signaling, . The dashed curve is the same link with every bit sent three times at a third of the energy each, decided by majority vote.
- Move the marker. At every , which is better?
- How many dB more would the voting link need to match the plain one at a BER of ?
Predict
Each bit is sent three times, each copy with a third of the bit's energy, and the receiver takes a majority vote of three hard decisions. Compared with sending each bit once at full energy, the error rate is:
Higher, at every noise level. Splitting the energy three ways makes each copy much noisier, and the vote can't recover what the hard decisions threw away. At 6 dB the plain link has a BER of 0.24% and the voting link 0.77%. Adding the three received voltages before deciding would exactly match the plain link, and real codes do much better than either by spreading each bit's information across many symbols cleverly.
Name it
Calibrating the noise
Antipodal signaling sends per bit. White noise of one-sided density , sampled by a matched receiver, adds Gaussian noise with variance to each symbol. With symbols scaled to (), the noise standard deviation is
and the error rate is . is quoted in dB: .
Measuring a BER curve
At each , send random bits, count the errors , and report with its error bar (lesson 31). Plot on a log scale: the curve drops like a cliff, because the Gaussian tail does.
Repetition and voting
Sending a bit as three copies, each with energy , gives each copy an error probability . A majority vote fails when two or three copies are wrong:
Fair comparisons hold the energy per bit fixed, and on that basis this code loses. Coding gain comes from codes that add redundancy more efficiently, and from soft decisions that use the received voltages rather than only their signs.
Worked example
What noise standard deviation corresponds to dB, for symbols of ±1?
Show the solution
- Convert from decibels.
- Noise standard deviation. a noise variance of 0.25.
- Expected BER.
Answer , a noise variance of 0.25, and the expected BER is 0.023.
Worked example
At dB, how do the plain and voting links compare?
Show the solution
- Convert from decibels. .
- Plain link.
- One copy in the voting link.
- Voting. about three times worse.
- Simulation. A simulation of 400,000 bits gives 0.0023 and 0.0077.
Answer the plain link has a BER of 0.0024 and the voting link 0.0077, about three times worse.
Check
Step 1. Write awgn(x, ebn0_db, rng) that adds Gaussian noise with standard deviation to the array x, with given in dB.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 2. Write ber(ebn0_db, n, rng): send n random bits as ±1, pass them through awgn, decide by the sign, and return the fraction wrong. awgn is included.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 3. Write rep3(ebn0_db, n, rng): send each of n bits as three copies of (so the energy per bit is still 1), add noise with awgn at the same , take a majority vote of the three signs, and return the BER. awgn is included.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 4. Using the formula (or your simulation), what BER does the three-copy voting link have at = 6 dB?
Explain why
Why does voting on three hard decisions lose to sending one bit at full energy?
The total energy per bit is fixed, so each copy gets a third of it, and its own error rate is much higher than the single full-energy symbol's. Each hard decision then throws away how confident it was: a copy that barely crossed zero counts as much as one far from it. The vote combines three unreliable yes-or-no answers, and two of the three being wrong is more likely than one full-energy symbol being wrong. Adding the voltages before deciding keeps the confidence information and recovers the plain link's performance, which is the idea behind soft-decision decoding.
Practice
Keep practicing
4 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.