---
title: Channel estimation and pilots
heading: Least-squares and MMSE channel estimates, the SNR they cost, how densely to place pilots in time and frequency, and frequency offsets from repeated preambles
eyebrow: S8 · Lesson 28 · Channel estimation and pilots
xp: 50
---

::: hook
Coherent detection, equalization, maximal-ratio combining and MIMO all assume the receiver knows the channel. It doesn't: it has to measure it, using **pilots**, known symbols the transmitter inserts among the data. Every pilot is a symbol that carries no information, and every estimate made from a few noisy pilots is itself noisy, so the receiver pays twice. How many pilots to send, how to space them across a channel that changes in time and frequency, and how to squeeze the most out of each one are the questions of this lesson.
:::

::: play
- The stems are the useful rate per symbol when a block of T symbols, over which the channel stays fixed, spends N of them on pilots: $(1 - N/T)\log_2\left(1 + \frac{\text{SNR}}{1 + 1/N}\right)$.
- Too few pilots and the noisy estimate costs SNR; too many and the overhead costs symbols. At 20 dB in a 100-symbol block the best is four.
- Shorten the block (a faster channel) and the best number of pilots falls while the loss grows.
:::

```sim plot
view: graph
x: N = 1..30
y: C = 0..10
samples: 30
slider: T = 20..400 = 100
slider: S = 0..30 = 20
plot: (1 - N/T)*log(1 + 10^(S/10)/(1 + 1/N))/log(2) | stems | label: useful rate with N pilots
plot: log(1 + 10^(S/10))/log(2) + 0*N | dashed | label: known channel
```

::: predict
## A receiver estimates a flat channel from one pilot sent at the same energy as the data, then detects coherently. How much SNR does the noisy estimate cost?

- [ ] Nothing, if the pilot is received correctly
- [ ] About 0.4 dB
- [x] About 3 dB
- [ ] About 10 dB

::: reveal
The least-squares estimate from one pilot has an error whose variance, relative to the channel's power, is 1/SNR. Used for detection, that error multiplies the data and adds an interference term as strong as the noise itself, so the effective SNR is $\text{SNR}/(1 + 1)$: half, 3 dB. Averaging N pilots cuts the loss to $10\log_{10}(1 + 1/N)$: 0.41 dB with ten.
:::
:::

::: nameit
## Pilots and the least-squares estimate

With a flat channel h, pilots x_p of energy E_p and noise of density N0, each received pilot is $y = hx_p + n$. The **least-squares** (LS) estimate averages $y/x_p$ over N pilots:
$$\hat h_\text{LS} = \frac{1}{N}\sum\frac{y_i}{x_{p,i}}, \qquad E|\hat h - h|^2 = \frac{N_0}{NE_p}$$
Relative to the channel's average power, the error variance is $1/(N\,\text{SNR}_p)$.

## The MMSE estimate

If the channel's statistics are known (Rayleigh with unit power), the **linear MMSE** estimate shrinks the LS one toward zero by $\frac{N\text{SNR}_p}{1 + N\text{SNR}_p}$ and has error variance
$$E|\hat h - h|^2 = \frac{1}{1 + N\,\text{SNR}_p}$$
much better than LS at low SNR, the same at high SNR. In OFDM the MMSE estimator also uses the correlation between subcarriers, set by the delay spread.

## What the error costs

Detecting with $\hat h$ instead of h leaves a term $(h - \hat h)x$ that behaves like extra noise of variance $\sigma_e^2E_s$. With pilots at the data's energy, the effective SNR is
$$\text{SNR}_\text{eff} = \frac{\text{SNR}}{1 + \text{SNR}\,\sigma_e^2} = \frac{\text{SNR}}{1 + 1/N}$$
for the LS estimate: a loss of $10\log_{10}(1 + 1/N)$ dB.

## Where to put pilots

An OFDM channel is a function of subcarrier and symbol, and pilots sample it. By the sampling theorem:
- in frequency, the response varies at "frequencies" up to the delay spread $\tau_\text{max}$, so pilots must be no more than $D_f \le 1/(\tau_\text{max}\,\Delta f)$ subcarriers apart;
- in time, it varies at up to the Doppler shift $f_d$, so pilots must be no more than $D_t \le 1/(2f_dT_s)$ symbols apart, with $T_s$ the symbol period including its prefix.

The overhead of a grid with one pilot per $D_f \times D_t$ cell is $1/(D_fD_t)$. Real systems place them closer than these limits, to leave margin for interpolation and to average noise.

## Frequency offset from a repeated preamble

If a preamble repeats every N samples, a frequency offset ε (cycles per sample) rotates each repetition by $2\pi N\varepsilon$, so
$$\hat\varepsilon = \frac{1}{2\pi N}\arg\sum_n y_{n+N}\,y_n^*$$
(Moose's estimator). The angle is unambiguous only within ±π, so a repetition period $T_r$ measures offsets up to $\pm 1/(2T_r)$: short repetitions give a coarse estimate over a wide range, long ones a fine estimate over a narrow one.
:::

::: example
## A link at 20 dB SNR estimates a flat channel by least squares. What effective SNR does it get from one pilot, and from four?

::: solution
1. **One pilot.**
   $$\begin{aligned} \text{SNR} &= \frac{100}{1 + 1} \\ &= 50 \\ &= 17.0\ \text{dB} \end{aligned}$$
   3.0 dB lost.
2. **Four pilots.**
   $$\begin{aligned} \text{SNR} &= \frac{100}{1 + 0.25} \\ &= 80 \\ &= 19.0\ \text{dB} \end{aligned}$$
   a loss of $10\log_{10}1.25$ = 0.97 dB.
3. **What sets the loss.** It doesn't depend on the SNR as long as the pilots have the data's energy: it's set by how many are averaged.

**Answer:** 17.0 dB with one pilot and 19.0 dB with four.
:::
:::

::: example
## An OFDM system at 2 GHz has 15 kHz subcarriers, 71.4 µs symbols (with prefix) and must work with 5 µs of delay spread at 350 km/h. How far apart may its pilots be?

::: solution
1. **Spacing in frequency.**
   $$\begin{aligned} D_f &\le \frac{1}{5\ \text{µs} \times 15\ \text{kHz}} \\ &= 13.3 \end{aligned}$$
   subcarriers.
2. **Doppler.**
   $$\begin{aligned} f_d &= \frac{vf_c}{c} \\ &= 649\ \text{Hz} \end{aligned}$$
3. **Spacing in time.**
   $$\begin{aligned} D_t &\le \frac{1}{2 \times 649\ \text{Hz} \times 71.4\ \text{µs}} \\ &= 10.8 \end{aligned}$$
   symbols.
4. **LTE.** LTE's reference signals sit every 6 subcarriers and twice in each 7-symbol slot, well inside both limits, leaving margin for interpolation and for averaging noise.

**Answer:** pilots may be up to 13.3 subcarriers apart in frequency and 10.8 symbols apart in time.
:::
:::

::: example
## A channel stays fixed for blocks of 100 symbols at 20 dB SNR. How many of each block's symbols should be pilots?

::: solution
1. **Useful rate.** With N pilots in each block of 100 it's
   $$(1 - N/100)\log_2\left(1 + \frac{100}{1 + 1/N}\right)$$
2. **Try a few values.** In bit/s/Hz:

| Pilots | Useful rate |
|---|---|
| 1 | 5.62 |
| 3 | 6.06 |
| 4 | 6.09 |
| 5 | 6.08 |
| 8 | 5.97 |

3. **The best choice.** Four is best, 0.57 bit/s/Hz (8.6%) below the 6.66 a known channel would give:
   $$6.66 - 6.09 = 0.57\ \text{bit/s/Hz}$$
4. **The gap.** That gap is the price of learning the channel.

**Answer:** four pilots per block, for 6.09 bit/s/Hz.
:::
:::

::: example
## Wi-Fi's preamble has short training symbols repeating every 0.8 µs and long ones repeating every 3.2 µs. Each radio's oscillator may be off by 20 ppm at 5.8 GHz. Which repetition can measure the offset?

::: solution
1. **Worst offset.** Between two radios it's
   $$\begin{aligned} \Delta f &= 40 \times 10^{-6} \times 5.8\ \text{GHz} \\ &= 232\ \text{kHz} \end{aligned}$$
2. **Short symbols.** They measure up to
   $$\pm\frac{1}{2 \times 0.8\ \text{µs}} = \pm 625\ \text{kHz}$$
   enough.
3. **Long symbols.** They measure only
   $$\pm\frac{1}{2 \times 3.2\ \text{µs}} = \pm 156\ \text{kHz}$$
   not enough on their own.
4. **Coarse, then fine.** So the receiver makes a coarse estimate from the short symbols, corrects it, then refines with the long symbols, whose longer spacing averages more noise.

**Answer:** only the short symbols can measure the full 232 kHz offset; the long ones refine the estimate afterward.
:::
:::

::: check
kind: parts
given: N = 2 | 4 | 10; S = 5 | 10 | 20

## A receiver estimates a flat channel by least squares from {N} pilot(s) at {S} dB SNR, the same energy as the data.

::: part
answer: 1/(N*10^(S/10))
tolerance: 0.5%

### What is the estimate's error variance, relative to the channel's power?

::: misses
- [1/10^(S/10)] Averaging N pilots divides it by N.
- [any] $1/(N\,\text{SNR}_p)$.
:::
:::

::: part
answer: S - 10*log(1 + 1/N)
unit: dB
tolerance: 0.5%

### What effective SNR does detection with the estimate reach?

::: misses
- [any] $\text{SNR}/(1 + 1/N)$.
:::
:::
:::

::: check
kind: parts
given: N = 1 | 2 | 4; S = -5 | 0 | 5

## A unit-power Rayleigh channel is estimated from {N} pilot(s) at {S} dB pilot SNR.

::: part
answer: 1/(1 + N*10^(S/10))
tolerance: 0.5%

### What is the LMMSE estimate's error variance?

::: misses
- [1/(N*10^(S/10))] That's the least-squares estimate.
- [any] $1/(1 + N\,\text{SNR}_p)$.
:::
:::

::: part
answer: (1 + N*10^(S/10))/(N*10^(S/10))
tolerance: 0.5%

### How many times larger is the least-squares estimate's error?

::: misses
- [any] Divide $1/(N\,\text{SNR}_p)$ by the MMSE error.
:::
:::
:::

::: check
kind: parts
given: d = 15 | 30 | 60; t = 1 | 3 | 5; f = 0.9 | 2 | 3.5; v = 60 | 120 | 350; s = 35.7 | 71.4

## An OFDM system has {d} kHz subcarriers and {s} µs symbols (with prefix) and must cope with {t} µs of delay spread at {v} km/h on a {f} GHz carrier.

::: part
answer: 1/(t*1e-6*d*1e3)
unit: subcarriers
tolerance: 0.5%

### How many subcarriers apart may its pilots be, at most?

::: misses
- [any] $1/(\tau_\text{max}\Delta f)$.
:::
:::

::: part
answer: 1/(2*v/3.6*f*1e9/299792458*s*1e-6)
unit: symbols
tolerance: 0.5%

### How many symbols apart, at most?

::: misses
- [1/(v/3.6*f*1e9/299792458*s*1e-6)] The Nyquist limit has a factor 2: $1/(2f_dT_s)$.
- [any] $1/(2f_dT_s)$ with $f_d = vf_c/c$.
:::
:::
:::

::: check
kind: parts
given: F = 3 | 4 | 6 | 12; T = 2 | 4 | 7

## An OFDM grid carries one pilot every {F} subcarriers in every {T}th symbol.

::: part
answer: 100/(F*T)
unit: %
tolerance: 0.5%

### What fraction of the grid is pilots?

::: misses
- [any] $1/(D_fD_t)$.
:::
:::
:::

::: check
kind: parts
given: N = 1 | 2 | 4 | 8; T = 20 | 50 | 100; S = 10 | 20

## A channel stays fixed for {T} symbols; {N} of them are pilots, at {S} dB SNR.

::: part
answer: (1 - N/T)*log(1 + 10^(S/10)/(1 + 1/N))/log(2)
unit: bits
tolerance: 0.5%

### What useful rate per symbol does the link reach?

::: misses
- [log(1 + 10^(S/10)/(1 + 1/N))/log(2)] The pilots carry no data: multiply by $1 - N/T$.
- [any] $(1 - N/T)\log_2\left(1 + \frac{\text{SNR}}{1 + 1/N}\right)$.
:::
:::
:::

::: check
kind: parts
given: r = 0.8 | 1.6 | 3.2 | 4; f = 2.4 | 5.8; p = 10 | 20

## A preamble repeats every {r} µs; radios at {f} GHz have oscillators within ±{p} ppm.

::: part
answer: 1/(2*r*1e-6)/1e3
unit: kHz
tolerance: 0.5%

### What is the largest offset the repetition can measure without ambiguity?

::: misses
- [1/(r*1e-6)/1e3] The angle is unambiguous only within ±π: $1/(2T_r)$.
- [any] $\pm 1/(2T_r)$.
:::
:::

::: part
answer: 2*p*1e-6*f*1e9/1e3
unit: kHz
tolerance: 0.5%

### What is the worst offset between two radios?

::: misses
- [p*1e-6*f*1e9/1e3] Both oscillators can be off, in opposite directions.
- [any] Twice the ppm tolerance times the carrier.
:::
:::
:::

::: check
kind: choice

## Why does the MMSE channel estimate beat least squares at low SNR but not at high SNR?

- [ ] It uses more pilots
- [x] It knows the channel's statistics and shrinks a noisy measurement toward the channel's average, which helps most when the measurement is mostly noise; at high SNR the shrinking factor approaches one and the two estimates agree
- [ ] It ignores the noise
- [ ] Least squares is biased at low SNR

::: misses
- [1] Both use the same pilots.
- [3] It weighs the noise explicitly.
- [4] Least squares is unbiased; its problem is variance.
:::
:::

::: check
kind: derivation
vars: N = 1..100, S = 0.01..10000, T = 100..10000

## A flat channel is estimated from N pilots at SNR S (linear), the same energy as the data, in blocks of T symbols.

::: step
answer: 1/(N*S)

### What is the least-squares error variance?
:::

::: step
answer: 1/(1 + N*S)

### What is the MMSE error variance for a unit-power Rayleigh channel?
:::

::: step
answer: (1 - N/T)*log(1 + S/(1 + 1/N))/log(2)

### What useful rate does the block carry with the LS estimate?
:::

::: right
Right. The pilot count trades estimation error against overhead, and the best balance depends on how long the channel stays still.
:::
:::

::: check
kind: python

## Write `interp_pilots(kp, hp, K)`: linear interpolation of complex channel estimates `hp` at increasing subcarrier indices `kp` onto all subcarriers 0 to K − 1 (hold the end values beyond the outermost pilots), and `moose(y, N)`: the frequency offset in cycles per sample from a preamble repeating every N samples.

```python starter
def interp_pilots(kp, hp, K):
    return [hp[0]] * K

def moose(y, N):
    return 0.0
```

```python solution
import cmath, math

def interp_pilots(kp, hp, K):
    out = []
    for k in range(K):
        if k <= kp[0]:
            out.append(hp[0]); continue
        if k >= kp[-1]:
            out.append(hp[-1]); continue
        i = max(j for j in range(len(kp)) if kp[j] <= k)
        t = (k - kp[i]) / (kp[i + 1] - kp[i])
        out.append((1 - t) * hp[i] + t * hp[i + 1])
    return out

def moose(y, N):
    s = sum(y[n + N] * y[n].conjugate() for n in range(len(y) - N))
    return cmath.phase(s) / (2 * math.pi * N)
```

```python tests
import cmath, math, random
H = lambda k: 1 + 0.5 * cmath.exp(1j * math.pi / 3) * cmath.exp(-2j * math.pi * k * 3 / 64)
kp = list(range(0, 64, 4)) + [63]
est = interp_pilots(kp, [H(k) for k in kp], 64)
assert all(abs(est[k] - H(k)) < 1e-12 for k in kp), "Exact at the pilots."
assert max(abs(est[k] - H(k)) for k in range(64)) < 0.09, "A 3-sample echo varies slowly enough for pilots every 4 subcarriers."
r = random.Random(5)
p = [cmath.exp(2j * math.pi * r.random()) for _ in range(16)]
y = [p[n % 16] * cmath.exp(2j * math.pi * 0.004 * n) + complex(r.gauss(0, 0.1), r.gauss(0, 0.1)) for n in range(64)]
assert abs(moose(y, 16) - 0.004) < 2e-4, "Offset 0.004 cycles per sample, measured from a 16-sample repetition."
```

::: right
Right. Interpolation works because pilots sample the channel faster than it varies, and Moose's estimator because a repetition turns a frequency into a phase.
:::
:::

::: explain
## Why must pilots be spaced according to both the delay spread and the Doppler spread?

::: model
The channel's response across an OFDM grid is a function of frequency and time, and pilots are samples of that function from which the rest must be interpolated. How fast the response changes across frequency is set by the delay spread: echoes arriving over a longer time make the response ripple over fewer subcarriers. How fast it changes in time is set by the Doppler spread: faster motion makes it change within fewer symbols. As with any sampling, the pilots must be closer together than the fastest variation, about one over the delay spread in frequency and one over twice the Doppler shift in time, or the interpolated channel will be wrong no matter how clean each pilot is.
:::
:::

::: practice
::: check
given: N = 1 | 3 | 6
answer: 10*log(1 + 1/N)
unit: dB
tolerance: 0.5%

## SNR lost to an LS estimate from {N} pilot(s) at the data's energy?

::: misses
- [any] $10\log_{10}(1 + 1/N)$.
:::
:::

::: check
given: t = 0.5 | 2 | 4; d = 15 | 78.125
answer: 1/(t*1e-6*d*1e3)
unit: subcarriers
tolerance: 0.5%

## Largest pilot spacing for {t} µs delay spread and {d} kHz subcarriers?

::: misses
- [any] $1/(\tau_\text{max}\Delta f)$.
:::
:::

::: check
given: r = 0.8 | 3.2 | 6.4
answer: 1/(2*r*1e-6)/1e3
unit: kHz
tolerance: 0.5%

## Offset range of a preamble repeating every {r} µs?

::: misses
- [any] $1/(2T_r)$.
:::
:::
:::
