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

S8 · Lesson 24 · Detection lab

Monte Carlo bit and symbol error rates for BPSK, 16-QAM and 8-PSK against their formulas, the MAP threshold for unequal priors, and how many bits a measurement needs

Every error-rate formula in lessons 12 to 20 rests on assumptions: Gaussian noise, perfect timing, a known channel, the right threshold. A simulation checks them all at once. You generate random symbols, add noise of exactly the right variance, decide, and count mistakes; if the count lands on the formula, the formula and the simulation agree about every scale factor. In this lab you'll build the simulations engineers use to check receivers, and learn how many bits it takes before a simulated error rate means anything.

  • The curves are BPSK's bit error probability on an AWGN channel, Q(2Eb/N0), and on a Rayleigh-fading channel, 12(1−γ¯/(1+γ¯)).
  • Measuring a rate of p to ±10% takes about 100 errors, so about 100/p bits: a million for 10⁻⁴, a hundred million for 10⁻⁶.
  • That cost is why simulations stop around 10⁻⁶ and why low error rates are extrapolated from formulas or measured with special techniques.

Predict

A simulation of a link whose true bit error rate is 10⁻⁵ should report that rate within about ±10%. How many bits must it send?

Name it

What the lab computes

  • Noise scaling. For symbols of average energy Es carrying log2⁡M bits, Eb=Es/log2⁡M, and each real noise dimension has variance N0/2. With unit-energy BPSK, σ=1/(2Eb/N0).
  • Square QAM. With levels ±1 and ±3 per axis (average Es = 10), each axis errs with PM=2(1−1/M)Q(3Es/((M−1)N0)), and the symbol error rate is 1−(1−PM)2.
  • M-PSK. At high SNR, Ps≈2Q(2Es/N0sin⁡(π/M)).
  • MAP threshold. For ±A with prior p1 on +A and noise σ, the threshold that minimizes errors is t=σ22Aln⁡1−p1p1, with error probability p1Q(A−tσ)+(1−p1)Q(A+tσ).
  • Confidence. n trials with true rate p give an estimate with standard deviation p(1−p)/n; a relative uncertainty r needs n=(1−p)/(pr2).

Check

Write ber_bpsk(EbN0_db, n, seed): send n random bits as ±1 through AWGN at the given Eb/N0, decide by sign, and return the fraction of errors. Use random.Random(seed).

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write ser_qam16(EbN0_db, n, seed): send n random 16-QAM symbols with levels ±1, ±3 per axis (Es = 10), add complex AWGN at the given Eb/N0, decide each axis by the nearest level, and return the symbol error rate.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write map_threshold(A, sigma, p1) and error_prob(A, sigma, p1, t) for antipodal ±A with prior p1 on +A, noise σ and threshold t.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write ser_mpsk(M, EsN0_db, n, seed): simulate n M-PSK symbols on the unit circle in complex AWGN at the given Es/N0, decide by the nearest phase, and return the symbol error rate; and bits_needed(p, rel): how many trials measure a rate p with relative standard deviation rel.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Why is a simulated error rate that matches its formula good evidence that a receiver model is right, and what can such a match fail to reveal?