A1153 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

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 Eb/N0, 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 Eb/N0, 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, Q(2Eb/N0). 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 Eb/N0, which is better?
  • How many dB more would the voting link need to match the plain one at a BER of 10−3?

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:

Name it

Calibrating the noise

Antipodal signaling sends ±Eb per bit. White noise of one-sided density N0, sampled by a matched receiver, adds Gaussian noise with variance N02 to each symbol. With symbols scaled to ±1 (Eb=1), the noise standard deviation is

σ=12Eb/N0

and the error rate is Q(1σ)=Q(2Eb/N0). Eb/N0 is quoted in dB: Eb/N0=10dB/10.

Measuring a BER curve

At each Eb/N0, send n random bits, count the errors k, and report p^=k/n with its error bar p^(1−p^)/n (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 Eb/3, gives each copy an error probability p=Q(2Eb/3N0). A majority vote fails when two or three copies are wrong:

Pb=3p2(1−p)+p3

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 Eb/N0=3 dB, for symbols of ±1?

Show the solution
  1. Convert from decibels. 100.3=2.0
  2. Noise standard deviation. σ=12×2.0=0.50 a noise variance of 0.25.
  3. Expected BER. Q(2.0)=0.023

Answer σ=0.50, a noise variance of 0.25, and the expected BER is 0.023.

Worked example

At Eb/N0=6 dB, how do the plain and voting links compare?

Show the solution
  1. Convert from decibels. Eb/N0=3.98.
  2. Plain link. Pb=Q(7.96)=Q(2.82)=0.0024
  3. One copy in the voting link. p=Q(7.96/3)=Q(1.63)=0.052
  4. Voting. Pb=3(0.052)2(0.948)+0.0523=0.0077 about three times worse.
  5. 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 1/(2Eb/N0) to the array x, with Eb/N0 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 ±13 (so the energy per bit is still 1), add noise with awgn at the same Eb/N0, 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 Eb/N0 = 6 dB?

Explain why

Why does voting on three hard decisions lose to sending one bit at full energy?

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.