---
title: Bit errors
heading: How noise turns into wrong bits, and how rarely
eyebrow: A11 · Lesson 41 · Bit errors, a preview of BER
xp: 40
---

::: hook
A digital receiver sees a voltage and has to decide: was that a 1 or a 0? Most of the time the noise is far too small to fool it. But Gaussian noise has tails that never quite end, so once in a while a noise spike carries the voltage across the threshold and a bit flips. How often depends on the signal-to-noise ratio, and very steeply: a few decibels can mean the difference between an error every second and one every year.

::: play
- Bits are sent as +1 V or −1 V, with Gaussian noise of RMS σ added. The receiver decides by the sign: the dashed line at zero is the threshold.
- Raise σ. Where do the two humps start to overlap? Every draw that lands on the wrong side of zero is a bit error.
- In the second sim only 1s are sent, and the readout counts how many land below zero. Compare it with $Q(1/\sigma)$. How many draws do you need before the count is trustworthy?
:::
:::

```sim plot
view: random
x: v = -3..3 V
slider: s = 0.1..1 step 0.05 = 0.4 V
sample: 2*coin(0.5) - 1 + s*randn(1)
trials: 20000
bins: 80
density: 0.5*exp(-(v - 1)^2/(2*s^2))/(s*sqrt(2*pi)) + 0.5*exp(-(v + 1)^2/(2*s^2))/(s*sqrt(2*pi))
marker: x = 0 | label: threshold
readout: bit error rate Q(1/σ) = Q(1/s) | format: sci
readout: SNR = 20*log10(1/s) dB
```

```sim plot
view: random
x: v = -2..4 V
slider: s = 0.2..1 step 0.05 = 0.4 V
slider: n = 100..200000 = 2000 log
sample: 1 + s*randn(1)
trials: n
bins: 60
marker: x = 0 | label: threshold
measure: step(-v) | name: E
readout: errors counted = E*n
readout: measured rate = E | format: sci
readout: theory Q(1/σ) = Q(1/s) | format: sci
```

::: predict
## A link has a bit error rate of $10^{-9}$ and runs at 1 Gb/s. About how often does a bit error happen?

- [ ] Never: $10^{-9}$ is essentially zero
- [x] About once a second
- [ ] About once a year
- [ ] About a billion times a second

::: reveal
About once a second: a billion bits a second times a one-in-a-billion chance each. Error rates that sound negligible aren't, at high data rates. That's why links add error-correcting codes, and why engineers care about the steep part of the curve: each extra dB of SNR near there divides the error rate by a large factor.
:::
:::

::: nameit
## Errors from noise

**Binary signaling.** Send $+A$ for a 1 and $-A$ for a 0, add Gaussian noise of RMS σ, and decide by the sign. A 1 is misread only if the noise is below $-A$, which has probability $Q(A/\sigma)$; a 0 is misread by symmetry with the same probability. So the **bit error rate** is

$$\text{BER} = Q\!\left(\frac{A}{\sigma}\right)$$

with $Q$ the Gaussian tail from lesson 16.

**It's steep.** Because the Gaussian tail falls off faster than exponentially, small changes in $A/\sigma$ make huge changes in the error rate:

| $A/\sigma$ | SNR, $20\log_{10}(A/\sigma)$ | BER |
|---|---|---|
| 2 | 6.0 dB | $2.3 \times 10^{-2}$ |
| 3 | 9.5 dB | $1.35 \times 10^{-3}$ |
| 4 | 12.0 dB | $3.2 \times 10^{-5}$ |
| 5 | 14.0 dB | $2.9 \times 10^{-7}$ |
| 6 | 15.6 dB | $9.9 \times 10^{-10}$ |

Going from 12 to 15.6 dB, less than a factor of 2.3 in power, cuts the error rate by more than 30,000 times. Plotted on a log scale against SNR, the BER curve drops like a waterfall, which is what it's called.

**Measuring it.** To see a rate of $p$, you need to send enough bits to get a fair number of errors: about $10/p$ bits for a rough estimate, since a count of $k$ errors is uncertain by about $\sqrt k$. At $10^{-12}$ and 10 Gb/s, that's about 17 minutes of testing.

**More to come.** Real links describe the SNR per bit as $E_b/N_0$, use many signal levels and shapes, and add coding. The constellation and eye diagrams in the communications courses build on exactly this calculation.
:::

::: example
## A 10 Gb/s link sends ±1 V with 0.25 V RMS of noise. What is its BER, and how many errors per second?

::: solution
1. **Signal over noise.**
   $$A/\sigma = 4$$
2. **BER.**
   $$\begin{aligned} \text{BER} &= Q(4) \\ &= 3.2 \times 10^{-5} \end{aligned}$$
3. **Errors per second.** At $10^{10}$ bits per second that's about 320,000 errors per second, far too many for most links.

**Answer:** the BER is $3.2 \times 10^{-5}$, about 320,000 errors per second.
:::
:::

::: example
## How much does doubling $A/\sigma$ from 3 to 6 change the BER?

::: solution
1. **At 3.**
   $$Q(3) = 1.35 \times 10^{-3}$$
2. **At 6.**
   $$Q(6) = 9.9 \times 10^{-10}$$
3. **Compare.** That's about 1.4 million times fewer errors for 6 dB more SNR. The Gaussian tail makes error rates fall off a cliff.

**Answer:** it cuts the BER about 1.4 million times, from $1.35 \times 10^{-3}$ to $9.9 \times 10^{-10}$.
:::
:::

::: example
## A link has $A/\sigma = 4$. What is its bit error rate?

::: solution
1. **BER.**
   $$\begin{aligned} \text{BER} &= Q(4) \\ &= 3.2 \times 10^{-5} \end{aligned}$$
   about one error in 31 600 bits.
2. **One more decibel.** Raising $A/\sigma$ to 4.49 cuts it to $3.6 \times 10^{-6}$, almost nine times lower, because the Gaussian tail falls so steeply.

**Answer:** the BER is $3.2 \times 10^{-5}$.
:::
:::

::: check
given: A = 0.5 | 1 | 2; r = 2 | 3 | 4; let s = A/r
answer: Q(r)
tolerance: 1%

## Bits are sent as ±{A} V with Gaussian noise of {s} V RMS, decided by sign. What is the bit error rate?

::: right
Right. $Q(A/\sigma) = Q(\given{r})$ = {answer}.
:::

::: misses
- [2*Q(r)] Each bit can only err in one direction: a 1 that's pushed below zero, or a 0 pushed above.
- [Q(A/(2*s))] The threshold is at zero, a full A away from either level.
- [any] Not yet. $\text{BER} = Q(A/\sigma)$.
:::
:::

::: check
given: ber = 1e-6 | 1e-9 | 1e-12; R = 1 | 10 | 100
answer: R*1e6*ber*3600
tolerance: 0.5%

## A link runs at {R} Mb/s with a bit error rate of {ber}. How many errors should you expect in an hour?

::: right
Right. Bits per hour times the error rate: {answer}.
:::

::: misses
- [R*1e6*ber] That's per second. Multiply by 3600 for an hour.
- [R*ber*3600] {R} Mb/s is {R} million bits per second.
- [any] Not yet. Expected errors $= $ bits sent × BER.
:::
:::

::: check
given: ber = 1e-6 | 1e-9 | 1e-12; R = 1 | 10
answer: 10/ber/(R*1e9)
unit: s
tolerance: 0.5%

## You want to see about 10 errors to measure a BER near {ber} on a {R} Gb/s link. How long must the test run?

::: right
Right. You need $10/\text{BER}$ bits, which at {R} Gb/s takes {answer}.
:::

::: misses
- [1/ber/(R*1e9)] That gets you about one error, too few to trust. Aim for about 10.
- [10/ber/R] {R} Gb/s is {R} × 10⁹ bits per second.
- [any] Not yet. Bits needed $\approx 10/\text{BER}$; divide by the bit rate.
:::
:::

::: check
given: snr = 6 | 9.5 | 12 | 14
answer: Q(10^(snr/20))
tolerance: 2%

## For ±A signaling, $20\log_{10}(A/\sigma)$ = {snr} dB. What is the BER?

::: right
Right. $A/\sigma = 10^{\given{snr}/20}$, and the BER is $Q$ of that: {answer}.
:::

::: misses
- [Q(10^(snr/10))] $A/\sigma$ is a voltage ratio: divide the dB by 20.
- [Q(snr)] Convert the dB to a ratio first.
- [any] Not yet. Turn the dB into $A/\sigma$, then take $Q$.
:::
:::

::: check
kind: choice

## A receiver's threshold drifts from 0 V to +0.2 V, with bits at ±1 V and Gaussian noise. What happens to the error rate?

- [ ] Nothing: the threshold doesn't matter
- [x] It rises: 1s now have less room before they're misread, and that loss outweighs the gain for 0s
- [ ] It falls, because 0s are safer
- [ ] It falls for both

::: right
Right. A 1 now errs when the noise is below −0.8 V instead of −1 V, and the Gaussian tail grows much faster than the other side's shrinks, so the total rises.
:::

::: misses
- [1] The threshold sets how much noise each symbol can tolerate.
- [3] 0s do get safer, but 1s get much less safe: the tail rises faster than it falls.
- [4] Moving the threshold toward one level always hurts that level.
:::
:::

::: check
kind: parts
given: k = 3 | 4 | 5; R = 1 | 10

## A {R} Gb/s link has $A/\sigma$ = {k}.

::: part
answer: Q(k)
tolerance: 0.5%

### What is its BER?

::: misses
- [2*Q(k)] With symbols $\pm A$ and the threshold at 0, only one tail counts.
- [any] $Q(A/\sigma)$.
:::
:::

::: part
answer: Q(k)*R*1e9
unit: errors/s
tolerance: 0.5%

### How many errors per second?

::: misses
- [any] BER times the bit rate.
:::
:::
:::

::: check
kind: derivation
vars: A = 0.5..2, s = 0.1..0.5

## Symbols are $\pm A$ with Gaussian noise $s$.

::: step
answer: A/s

### How many standard deviations separate a symbol from the threshold?
:::

::: step
answer: Q(A/s)

### What is the error rate?
:::

::: right
Right. Everything depends on $A/\sigma$.
:::
:::

::: check
kind: python

## Simulate 10⁶ bits of ±1 with Gaussian noise of σ = 0.5 (`np.random.default_rng(6)`), decide by sign, and set `ber_sim`; set `ber_q` to $Q(2)$ computed with `math.erfc`.

```python starter
import math
import numpy as np

ber_sim = ber_q = 0.0
print(ber_sim, ber_q)
```

```python solution
import math
import numpy as np

rng = np.random.default_rng(6)
bits = rng.integers(0, 2, 10**6) * 2 - 1
received = bits + rng.normal(0, 0.5, 10**6)
ber_sim = np.mean(np.sign(received) != bits)
ber_q = 0.5 * math.erfc(2 / math.sqrt(2))
print(ber_sim, ber_q)
```

```python tests
assert abs(ber_q - 0.0227501) < 1e-6, "Q(2) = 0.02275."
assert abs(ber_sim - ber_q) < 0.0005, f"The simulated BER should match Q(2); got {ber_sim}."
```

::: right
Right. About 2.3% of bits flip at $A/\sigma = 2$, as $Q(2)$ says.
:::
:::

::: explain
## Why does a small increase in SNR reduce the bit error rate so dramatically?

::: model
A bit error needs the noise to exceed the gap between the signal level and the threshold. For Gaussian noise the chance of exceeding a value falls off like $e^{-x^2/2}$, faster than exponentially, so near the tail every extra bit of margin removes a much larger share of the remaining probability than the last. Raising the signal by a few dB moves the threshold several tenths of a standard deviation further into the tail, which can cut the error rate by orders of magnitude.
:::
:::

::: practice

::: check
given: z = 2 | 3 | 4 | 5
answer: Q(z)
tolerance: 1%

## What is $Q(\given{z})$?

::: misses
- [2*Q(z)] That's both tails.
- [any] The Gaussian tail beyond {z}σ.
:::
:::

::: check
given: n = 1e9 | 1e10 | 1e12; ber = 1e-9 | 1e-10
answer: n*ber
tolerance: 0.5%

## About how many errors do you expect in {n} bits at a BER of {ber}?

::: misses
- [any] Bits × BER.
:::
:::

::: check
given: A = 1 | 2 | 3
answer: A/6
unit: V
tolerance: 2%

## Bits are ±{A} V. About how much RMS noise gives a BER near $10^{-9}$?

::: misses
- [A/3] $Q(3)$ is about $10^{-3}$. You need about 6σ of margin.
- [any] $Q(6) \approx 10^{-9}$, so $\sigma \approx A/6$.
:::
:::
:::
