Algorithm Search⌘K

Algorithmcore

Mueller and Muller timing recovery

Also called Mueller-Muller detector, M and M timing detector.

A decision-directed timing loop at one sample per symbol. Its error is the strobe times the previous decision minus the previous strobe times the current decision.

Time
O(N M) worstO(N) qpsk_or_square_qam
Space
O(1) extra
Where
M = the number of constellation points; N = the number of symbols
Properties
not carrier phase invariantdecision directeddeterministiconline
Origin
Kurt H. Mueller, Markus Müller, 1976

Mueller and Muller timing recovery is a decision-directed feedback loop for symbol timing recovery that needs only one sample per symbol. At each strobe it makes a decision a^k\hat a_k, or uses a known symbol, and forms the error ek=Re⁡{a^k−1‾ yk−a^k‾ yk−1}e_k = \operatorname{Re}\{\overline{\hat a_{k-1}}\,y_k - \overline{\hat a_k}\,y_{k-1}\}. With correct decisions the mean of eke_k is g(1−Δ)−g(1+Δ)g(1 - \Delta) - g(1 + \Delta), the difference between the pulse sample one symbol after the strobe and the one one symbol before it. So the loop settles where these two samples are equal, which is the peak for a symmetric pulse. For a pulse that meets the Nyquist criterion, the error at lock is exactly zero for every data sequence, so there is no self-noise, unlike the Gardner detector and the early-late gate. The price is that the loop needs the carrier phase and correct decisions. The loop filter and accumulator are those of a phase-locked loop. The detector is common in receivers that run at the symbol rate, such as those with a symbol-spaced equalizer and many wireline links.

In plain words

Each received pulse spreads a little into the time slots of its neighbors. If the receiver reads at the right instant, the parts that leak one slot forward and one slot backward are equal and cancel out in a suitable comparison. If it reads too early, more leaks forward than backward. The detector cannot see the leak directly, so it uses its own decisions about the symbols to separate it from the data. It compares the current reading with the previous symbol, and the previous reading with the current symbol, and the difference shows which way the timing is off. Only one reading per symbol is needed. The decisions must be mostly right, and the receiver must already know the phase of the carrier.

The problem

Times are in symbol periods, T=1T = 1. After carrier phase correction, the receiver can sample the matched filter output

y(t)=∑mam g(t−m−τ)+v(t)y(t) = \sum_m a_m\,g(t - m - \tau) + v(t)

once per symbol, at times it controls, with an adjustable clock or with an interpolator. The overall pulse gg is real and even, the symbols ama_m come from a constellation such as QAM or PSK, independent with Eam=0E a_m = 0 and E∣am∣2=1E|a_m|^2 = 1, vv is filtered noise with SNR=Es/N0\mathrm{SNR} = E_s/N_0, and the delay τ\tau is unknown and may drift. The loop must output τk\tau_k such that the strobes yk=y(k+τk)y_k = y(k + \tau_k) fall on the symbol instants.

The algorithm

  1. MUELLER-MULLER(y, N, Kp, Ki, tau0, points, known)
  2. 1tau <- tau0; s <- 0
  3. 2for k <- 0 to N - 1 do
  4. 3yk <- y(k + tau); est[k] <- tau
  5. 4ak <- known[k] if known symbols are given, else the nearest point to yk
  6. 5if k > 0 then
  7. 6e <- Re(conj(a_prev) * yk - conj(ak) * y_prev)
  8. 7s <- s + Ki * e ▷ loop filter
  9. 8tau <- tau + Kp * e + s ▷ timing accumulator
  10. 9y_prev <- yk; a_prev <- ak
  11. 10return est, strobes, decisions

Line L4 is the slicer of a minimum distance detector; with a preamble the same loop is data-aided. Line L6 is the detector. It is positive when the strobe is early, so line L8 adds it. Lines L7 and L8 are the PLL loop with the delay in place of the phase. The detector slope at lock is KD=−2g′(1)K_D = -2g'(1), which for a raised cosine with roll-off β\beta is 2cos⁡(πβ)/(1−4β2)2\cos(\pi\beta)/(1 - 4\beta^2): 22 at β=0\beta = 0, π/2\pi/2 at β=12\beta = \frac12 and 23\frac23 at β=1\beta = 1. A first-order loop with noise bandwidth BLTB_LT uses Kp=4BLT/((1+2BLT)KD)K_p = 4B_LT/\bigl((1 + 2B_LT)K_D\bigr).

Example

Take QPSK data (seed 1), a raised cosine with β=0.5\beta = 0.5, the true delay τ=0.3\tau = 0.3, no noise, BLT=0.01B_LT = 0.01 and Ki=0K_i = 0, so Kp=0.024965K_p = 0.024965. The loop starts at τ0=0\tau_0 = 0. At k=0k = 0 there is no previous symbol, so the loop only stores y0=−0.702+0.490jy_0 = -0.702 + 0.490j and its decision 12(−1+j)\frac{1}{\sqrt2}(-1 + j):

kk τk\tau_k yky_k (L3) a^k2\hat a_k \sqrt2 (L4) eke_k (L6) τk+1\tau_{k+1} (L8)
1 00 0.471+0.934j0.471 + 0.934j 1+j1 + j 0.4771370.477137 0.0119120.011912
2 0.0119120.011912 −0.410−0.537j-0.410 - 0.537j −1−j-1 - j 0.3245610.324561 0.0200150.020015
3 0.0200150.020015 0.272+0.426j0.272 + 0.426j 1+j1 + j 0.1755860.175586 0.0243980.024398

At Δ=0.3\Delta = 0.3 the mean error is g(0.7)−g(1.3)=0.457816g(0.7) - g(1.3) = 0.457816. Every decision of the run is correct, even at the start: a QPSK eye with this roll-off is still open at an offset of 0.30.3. The error τ−τk\tau - \tau_k is 0.2250.225 at k=10k = 10, 0.1240.124 at 2525, 0.0380.038 at 5050, 4.2×10−34.2 \times 10^{-3} at 100100, 7.8×10−57.8 \times 10^{-5} at 200200 and 2.7×10−82.7 \times 10^{-8} at 400400. It keeps falling geometrically, because the error at lock is exactly zero: the loop has no self-noise.

In noise at Es/N0=10E_s/N_0 = 10 dB with BLT=0.01B_LT = 0.01, three runs of 2400 symbols (seeds 7, 8 and 9) measured a variance of 2.762.76 to 3.623.62 times the loop form of the MCRB, 2.66×10−42.66 \times 10^{-4}. The closed form below predicts 3.053.05.

Correctness

Claim. With correct decisions, independent zero-mean data and τk\tau_k held fixed, the mean of eke_k is g(1−Δ)−g(1+Δ)g(1 - \Delta) - g(1 + \Delta), Δ=τ−τk\Delta = \tau - \tau_k, so Δ=0\Delta = 0 is a stable point with slope KD=−2g′(1)K_D = -2g'(1). If gg is a Nyquist pulse, ek=0e_k = 0 at Δ=0\Delta = 0 for every data sequence when there is no noise. For PSK with correct decisions, the linear model gives the loop variance 2BLT N0/KD22B_LT\,N_0/K_D^2, which is 32ξ=3.0532\xi = 3.05 times the loop MCRB for β=12\beta = \frac12.

Key steps. The mean of ak−1‾ yk\overline{a_{k-1}}\,y_k picks the coefficient of ak−1a_{k-1} in yky_k, which is g(1−Δ)g(1 - \Delta); the mean of ak‾ yk−1\overline{a_k}\,y_{k-1} is g(−1−Δ)=g(1+Δ)g(-1 - \Delta) = g(1 + \Delta). At lock a Nyquist pulse gives yk=aky_k = a_k, and then ak−1‾ak−ak‾ak−1\overline{a_{k-1}}a_k - \overline{a_k}a_{k-1} is purely imaginary, so its real part is zero. The noise samples at the symbol rate are white with variance N0N_0, and the two noise terms of eke_k add up to the variance N0N_0. The full proof is in the proofs file.

The S-curve and the zero self-noise are theorems under the stated assumptions. The variance is a closed form under assumptions: the linear model, correct decisions and white detector noise. The measured ratios are a measurement.

Proof: The Mueller and Muller detector has the S-curve g(1 - Delta) - g(1 + Delta), it has no self-noise at lock for a Nyquist pulse, and its loop variance is 32 xi times the MCRB at high SNRfull

Times are in symbol periods, T=1T = 1. After carrier phase correction, the matched filter output is y(t)=∑mamg(t−m−τ)+v(t)y(t) = \sum_m a_m g(t - m - \tau) + v(t). The overall pulse gg is real and even, the data are independent with Eam=0E a_m = 0 and E∣am∣2=1E|a_m|^2 = 1, and the noise vv is independent of the data, stationary, with zero mean and autocorrelation E[v(t)v(s)‾]=N0 g(t−s)E[v(t)\overline{v(s)}] = N_0\,g(t - s), as at the output of a matched filter. Line L3 takes the strobe yk=y(k+τk)y_k = y(k + \tau_k), line L4 gives the symbol a^k\hat a_k (a decision, or a known symbol), and line L6 forms

ek=Re⁡{a^k−1‾ yk−a^k‾ yk−1}.e_k = \operatorname{Re}\bigl\{\overline{\hat a_{k-1}}\,y_k - \overline{\hat a_k}\,y_{k-1}\bigr\}.

Write Δ=τ−τk\Delta = \tau - \tau_k, and take τk=τk−1\tau_k = \tau_{k-1} while the mean is taken.

Theorem 1 (S-curve with correct symbols). If a^k=ak\hat a_k = a_k for all kk, then E[ek]=g(1−Δ)−g(1+Δ)E[e_k] = g(1 - \Delta) - g(1 + \Delta).

Proof. yk=∑mamg(k−m−Δ)+vky_k = \sum_m a_m g(k - m - \Delta) + v_k. Since the data are independent with mean zero and E∣a∣2=1E|a|^2 = 1, E[ak−1‾ yk]=g(k−(k−1)−Δ)=g(1−Δ)E[\overline{a_{k-1}}\,y_k] = g(k - (k - 1) - \Delta) = g(1 - \Delta), and E[ak‾ yk−1]=g(−1−Δ)=g(1+Δ)E[\overline{a_k}\,y_{k-1}] = g(-1 - \Delta) = g(1 + \Delta) because gg is even. The noise is independent of the data and has mean zero. □\square

So the S-curve is odd in Δ\Delta and zero at Δ=0\Delta = 0. Its slope there is KD=−2g′(1)K_D = -2g'(1). For the raised cosine pulse with roll-off β\beta, g′(1)=−cos⁡(πβ)/(1−4β2)g'(1) = -\cos(\pi\beta)/(1 - 4\beta^2), so KD=2cos⁡(πβ)/(1−4β2)K_D = 2\cos(\pi\beta)/(1 - 4\beta^2), with the limit π/2\pi/2 at β=12\beta = \frac12. KD>0K_D > 0 for 0≤β<10 \le \beta < 1, so Δ=0\Delta = 0 is a stable point of the loop of lines L7 and L8 with Kp>0K_p > 0.

Lemma 1 (no self-noise at lock). If gg satisfies the Nyquist condition g(m)=δmg(m) = \delta_m, Δ=0\Delta = 0, there is no noise and the symbols are correct, then ek=0e_k = 0 for every data sequence.

Proof. At Δ=0\Delta = 0, yk=∑mamg(k−m)=aky_k = \sum_m a_m g(k - m) = a_k. Then ek=Re⁡{ak−1‾ak−ak‾ak−1}=Re⁡{2jIm⁡(ak−1‾ak)}=0e_k = \operatorname{Re}\{\overline{a_{k-1}}a_k - \overline{a_k}a_{k-1}\} = \operatorname{Re}\{2j\operatorname{Im}(\overline{a_{k-1}}a_k)\} = 0. □\square

So τk=τ\tau_k = \tau is an exact fixed point of the loop for random data, not only for a special pattern. This is the main difference from the early-late gate and the Gardner detector, which have self-noise.

Lemma 2 (noise at lock). At Δ=0\Delta = 0 with correct symbols from a PSK constellation (∣a∣=1|a| = 1), the detector output is ek=Re⁡{ak−1‾vk−ak‾vk−1}e_k = \operatorname{Re}\{\overline{a_{k-1}}v_k - \overline{a_k}v_{k-1}\}. The samples vkv_k are white CN(0,N0)\mathcal{CN}(0, N_0), E[ek2]=N0E[e_k^2] = N_0, and E[ekek+1]=0E[e_k e_{k+1}] = 0 averaged over the data. So the noise of the detector has the spectral density S(0)=N0S(0) = N_0.

Proof. The first claim is Lemma 1 plus the noise. E[vkvk′‾]=N0g(k−k′)=N0δk−k′E[v_k\overline{v_{k'}}] = N_0 g(k - k') = N_0\delta_{k-k'}, so the samples are white. For a complex zz with independent parts of variance σ2/2\sigma^2/2, E[(Re⁡{a‾z})2]=∣a∣2σ2/2E[(\operatorname{Re}\{\overline{a}z\})^2] = |a|^2\sigma^2/2. The two terms of eke_k use different noise samples, so E[ek2]=N02+N02=N0E[e_k^2] = \frac{N_0}{2} + \frac{N_0}{2} = N_0. The pair ek,ek+1e_k, e_{k+1} shares only vkv_k, and its covariance is −N02Re⁡{ak−1‾ak+1}-\frac{N_0}{2}\operatorname{Re}\{\overline{a_{k-1}}a_{k+1}\}, whose mean over the independent data is zero. Pairs further apart share no noise sample. □\square

Theorem 2 (loop variance). In the linear model of a first-order loop with noise bandwidth BLTB_L T, correct symbols and PSK data, the variance of τk\tau_k is στ2=2BLT N0/KD2\sigma_\tau^2 = 2B_LT\,N_0/K_D^2. In units of the loop form of the MCRB, BLT/(4π2ξ SNR)B_LT/(4\pi^2\xi\,\mathrm{SNR}) with SNR=1/N0\mathrm{SNR} = 1/N_0,

στ2MCRB=8π2ξKD2.\frac{\sigma_\tau^2}{\mathrm{MCRB}} = \frac{8\pi^2\xi}{K_D^2}.

For β=12\beta = \frac12, KD=π/2K_D = \pi/2 and ξ=0.0951727\xi = 0.0951727, the ratio is 32ξ=3.045532\xi = 3.0455.

Proof. The linear model of the phase-locked loop gives the variance 2BLT S(0)/KD22B_LT\,S(0)/K_D^2 for a detector with slope KDK_D and white noise of density S(0)S(0). Lemma 2 gives S(0)=N0S(0) = N_0. Divide by the bound. □\square

The variance is a closed form under assumptions: the linear model, correct decisions, and white noise at the detector output. It holds at high SNR; at low SNR wrong decisions add errors and bend the S-curve. The tests measure ratios of 2.762.76 to 3.623.62 at 10 dB over three seeds, against 3.053.05. The detector is not phase invariant: it needs the carrier phase, since the symbol a^k\hat a_k and the strobe yky_k are compared directly.

Complexity

Each symbol needs one sample (line L3), one decision, the real parts of two complex products (four real multiplications and three additions) and the four operations of lines L7 and L8. A slicer that tries all MM points costs O(M)O(M); for QPSK and square QAM, slicing each axis separately costs O(1)O(1). So the loop costs O(NM)O(NM) in general and O(N)O(N) for QPSK and square QAM, for NN symbols in the real RAM, with O(1)O(1) extra space besides the output. With an interpolator of KK taps, add KK multiply-adds per symbol.

Properties

  • One sample per symbol. This is the lowest possible rate. It suits receivers whose analog-to-digital converter or equalizer runs at the symbol rate.
  • No self-noise at lock. For a Nyquist pulse the detector output is exactly zero at the correct timing, whatever the data. The loop variance comes from the noise alone.
  • Works with small roll-off. The slope is 22 at β=0\beta = 0 and π/2\pi/2 at β=0.5\beta = 0.5, so the detector keeps its gain when the excess bandwidth is small, where square-law detectors lose theirs.
  • Needs the carrier phase. A phase error ϕ\phi rotates yky_k against a^k\hat a_k and scales the useful part of the error by cos⁡ϕ\cos\phi; at large ϕ\phi the decisions fail. Timing and carrier loops must therefore run together, or a data-aided start must come first.
  • Lock point for unequal pulse sides. If the channel makes the pulse asymmetric, the loop locks where g(1−Δ)=g(1+Δ)g(1 - \Delta) = g(1 + \Delta), which is not the peak. With an equalizer after the sampler this is often a good point, but it is a different criterion.

Variants and improvements

  • Data-aided form. With known symbols in line L4 the loop works at any SNR and from any start inside its pull-in range. The tests start it at τ0=−0.15\tau_0 = -0.15 with a delay of 0.30.3, an error of 0.450.45, and it locks exactly.
  • Real baseband form. For PAM, ek=a^k−1yk−a^kyk−1e_k = \hat a_{k-1}y_k - \hat a_k y_{k-1}, which is the form in the paper.
  • Other timing functions. Mueller and Müller derive a family of timing functions, each zero at a different combination of pulse samples. The one on this page is the symmetric member.
  • Second-order loop. Ki>0K_i > 0 follows a clock frequency offset with zero mean error, as in the PLL.
  • Baud-rate clock recovery in wireline links. Serial links that sample once per bit use detectors of this kind, often with the decisions of an adaptive equalizer.

When to use it

Use Mueller and Muller timing recovery when the receiver samples at the symbol rate, the carrier phase is known or tracked jointly, and the SNR is high enough that most decisions are correct. It is also a good tracking loop after a data-aided start from a preamble. When the timing must lock before the carrier, use the Gardner detector at two samples per symbol. When the SNR is low, decision errors bend the S-curve, and a non-data-aided detector or a data-aided detector on pilots is safer.

Pitfalls

  • Wrong sign of the update. With the convention here, ek>0e_k > 0 when the strobe is early. Some texts write the error with the opposite sign and subtract it.
  • Running it before the carrier loop has locked. Without the carrier phase, the decisions are wrong for a large share of the symbols and the detector output has no useful mean. Start with a data-aided phase or a phase-free timing detector.
  • Decision errors at low SNR. Each wrong decision gives a wrong error value, and at low SNR the slope shrinks. The variance then exceeds the closed form.
  • Hang-up at a bad start. If the start is about half a symbol off, the eye is closed and the decisions are random, so the loop can stay there for a long time. Use a preamble or a non-data-aided detector for acquisition.
  • Gain not divided by KDK_D. KDK_D depends on the pulse and on the signal level; use the slope of the actual pulse.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

mueller_muller_timing_recovery.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/mueller-muller-timing-recovery/. The authors are listed in prov/BY94Z6.jsonl.

"""Mueller and Muller timing recovery (1976): a decision-directed loop at one sample per symbol.

Times are in symbol periods T. The receiver has a sampler y(t) for the matched
filter output, after carrier phase correction: an ADC whose clock the loop
controls, or an interpolator. At each symbol it takes one sample
y_k = y(k + tau_k), makes a decision a_k (or uses a known symbol) and forms

    e_k = Re{ conj(a_{k-1}) y_k - conj(a_k) y_{k-1} }.

With correct decisions and i.i.d. data with E|a|^2 = 1, the mean of e_k is
g(1 - delta) - g(1 + delta) for the overall pulse g and delta = tau - tau_k.
So the loop settles where the pulse samples one symbol before and one symbol
after the strobe are equal. For a symmetric pulse this is the peak. e_k > 0
when the receiver samples too early, and the loop moves tau up:

    s <- s + ki e_k,   tau_{k+1} = tau_k + kp e_k + s.
"""

import math
from typing import Callable, Optional, Sequence

Sampler = Callable[[float], complex]


def slicer(y: complex, points: Sequence[complex]) -> complex:
    """The nearest point of the constellation (minimum distance decision)."""
    return min(points, key=lambda p: abs(y - p))


def detector(prev_y: complex, prev_a: complex, y: complex, a: complex) -> float:
    """The Mueller and Muller error from two strobes and their symbols."""
    return (prev_a.conjugate() * y - a.conjugate() * prev_y).real  # @line L6


def slope_raised_cosine(beta: float) -> float:
    """Slope at lock, -2 g'(1), for a raised cosine pulse with roll-off beta."""
    if abs(beta - 0.5) < 1e-12:
        return math.pi / 2.0
    return 2.0 * math.cos(math.pi * beta) / (1.0 - 4.0 * beta * beta)


def gain_for_bandwidth(bl_t: float, kd: float) -> float:
    """kp of a first-order loop with noise bandwidth B_L T for the detector slope kd."""
    return 4.0 * bl_t / ((1.0 + 2.0 * bl_t) * kd)


def mueller_muller(
    sample: Sampler,
    n: int,
    kp: float,
    points: Sequence[complex],
    ki: float = 0.0,
    tau0: float = 0.0,
    known: Optional[Sequence[complex]] = None,
) -> tuple[list[float], list[complex], list[complex]]:
    """Run the loop over n symbols. With known symbols it is data-aided, else decision-directed.

    Return the estimates tau_k, the strobes y_k and the symbols a_k used.
    """
    tau, s = tau0, 0.0  # @line L1
    prev_y, prev_a = 0j, 0j
    taus: list[float] = []
    ys: list[complex] = []
    decisions: list[complex] = []
    for k in range(n):  # @line L2
        taus.append(tau)
        y = sample(k + tau)  # @line L3
        a = known[k] if known is not None else slicer(y, points)  # @line L4
        ys.append(y)
        decisions.append(a)
        if k > 0:  # @line L5
            e = detector(prev_y, prev_a, y, a)  # @line L6
            s += ki * e  # @line L7
            tau += kp * e + s  # @line L8
        prev_y, prev_a = y, a  # @line L9
    return taus, ys, decisions  # @line L10
test_mueller_muller_timing_recovery.py 146 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/mueller-muller-timing-recovery/. The authors are listed in prov/BY94Z6.jsonl.

import cmath
import math
import random

from mueller_muller_timing_recovery import (
    detector,
    gain_for_bandwidth,
    mueller_muller,
    slicer,
    slope_raised_cosine,
)

BETA = 0.5
TAU = 0.3
QPSK = [cmath.exp(1j * (math.pi / 4 + m * math.pi / 2)) for m in range(4)]


def rc(t, b):
    """The raised cosine pulse with roll-off b and T = 1."""
    if abs(t) < 1e-12:
        return 1.0
    if abs(abs(t) - 1 / (2 * b)) < 1e-9:
        return math.pi / 4 * math.sin(math.pi / (2 * b)) / (math.pi / (2 * b))
    return math.sin(math.pi * t) / (math.pi * t) * math.cos(math.pi * b * t) / (1 - (2 * b * t) ** 2)


def rrc(t, b):
    """The root raised cosine pulse with roll-off b and T = 1."""
    if abs(t) < 1e-12:
        return 1 - b + 4 * b / math.pi
    if abs(abs(t) - 1 / (4 * b)) < 1e-9:
        return b / math.sqrt(2) * ((1 + 2 / math.pi) * math.sin(math.pi / (4 * b)) + (1 - 2 / math.pi) * math.cos(math.pi / (4 * b)))
    return (math.sin(math.pi * (1 - b) * t) + 4 * b * t * math.cos(math.pi * (1 + b) * t)) / (math.pi * t * (1 - (4 * b * t) ** 2))


def make_sampler(a, tau, n0=0.0, seed=0, span=4, reach=8):
    """Matched filter output y(t) = sum a_k g(t - k - tau) + v(t), g raised cosine.

    The noise is v(t) = sum_n w_n rrc(t - n h) with h = 1/2 and w_n i.i.d.
    CN(0, h n0). Since rrc has bandwidth (1 + beta)/2 < 1/(2h), v is stationary
    with autocorrelation n0 g(t - s): the matched filter output of white noise
    of density n0 (up to the cut of rrc at span symbols).
    """
    h = 0.5
    n_lo = int(-6 / h)
    w = None
    if n0 > 0:
        rng = random.Random(seed)
        sd = math.sqrt(h * n0 / 2)
        w = [complex(rng.gauss(0, sd), rng.gauss(0, sd)) for _ in range(int((len(a) + 12) / h))]
    reach_w = int(span / h)

    def sample(t):
        k0 = int(round(t - tau))
        acc = 0j
        for k in range(max(0, k0 - reach), min(len(a), k0 + reach + 1)):
            acc += a[k] * rc(t - k - tau, BETA)
        if w is not None:
            c = int(round(t / h))
            for n in range(c - reach_w, c + reach_w + 1):
                acc += w[n - n_lo] * rrc(t - n * h, BETA)
        return acc

    return sample


def qpsk(n, seed):
    rng = random.Random(seed)
    return [rng.choice(QPSK) for _ in range(n)]


def rc_derivative_at_one(b, eps=1e-6):
    return (rc(1 + eps, b) - rc(1 - eps, b)) / (2 * eps)


def test_slope_formula():
    for b in (0.1, 0.25, 0.35, 0.5, 0.75):
        assert abs(slope_raised_cosine(b) + 2 * rc_derivative_at_one(b)) < 1e-6
    assert abs(slope_raised_cosine(0.5) - math.pi / 2) < 1e-15


def test_slicer_is_nearest_point():
    rng = random.Random(1)
    for _ in range(200):
        y = complex(rng.gauss(0, 1), rng.gauss(0, 1))
        best = slicer(y, QPSK)
        assert all(abs(y - best) <= abs(y - p) for p in QPSK)


def test_decision_directed_lock_is_exact_without_noise():
    # At tau_k = tau the strobes are the symbols (raised cosine is a Nyquist
    # pulse), so e_k = Re{conj(a_{k-1}) a_k - conj(a_k) a_{k-1}} = 0: no self-noise.
    a = qpsk(700, 2)
    kp = gain_for_bandwidth(0.01, slope_raised_cosine(BETA))
    taus, ys, dec = mueller_muller(make_sampler(a, TAU), 650, kp, QPSK)
    for t in taus[500:]:
        # rc() takes its limit value within 1e-9 of t = 1/(2 beta), so 1e-8 is the floor here.
        assert abs(t - TAU) < 1e-8
    assert dec[500:650] == a[500:650]


def test_data_aided_lock_from_far_start():
    a = qpsk(700, 3)
    kp = gain_for_bandwidth(0.01, slope_raised_cosine(BETA))
    taus, _, _ = mueller_muller(make_sampler(a, TAU), 650, kp, QPSK, tau0=-0.15, known=a)
    for t in taus[600:]:
        # rc() takes its limit value within 1e-9 of t = 1/(2 beta), so 1e-8 is the floor here.
        assert abs(t - TAU) < 1e-8


def test_detector_mean_matches_s_curve():
    a = qpsk(1300, 4)
    sample = make_sampler(a, TAU)
    for delta in (0.1, 0.3, -0.2):
        es = []
        for k in range(10, 1290):
            t = k + TAU - delta
            es.append(detector(sample(t - 1), a[k - 1], sample(t), a[k]))
        mean = sum(es) / len(es)
        expected = rc(1 - delta, BETA) - rc(1 + delta, BETA)
        # The standard error of the mean is about 0.02 here.
        assert abs(mean - expected) < 0.06
    assert abs(rc(0.9, BETA) - rc(1.1, BETA) - 0.156597) < 1e-6
    assert abs(rc(0.7, BETA) - rc(1.3, BETA) - 0.457816) < 1e-6


def test_noise_variance_against_mcrb():
    # The detector noise is white with variance N0 per symbol (Nyquist pulse),
    # so a first-order loop has var = 2 B_L T N0 / K_D^2. Divided by the MCRB
    # this is 8 pi^2 xi / K_D^2 = 32 xi = 3.05 at beta = 0.5.
    snr = 10.0
    bl_t = 0.01
    xi = 1.0 / 12.0 + BETA ** 2 * (0.25 - 2.0 / math.pi ** 2)
    mcrb = bl_t / (4 * math.pi ** 2 * xi * snr)
    a = qpsk(2400, 6)
    sample = make_sampler(a, TAU, n0=1.0 / snr, seed=7)
    kd = slope_raised_cosine(BETA)
    taus, _, _ = mueller_muller(sample, 2350, gain_for_bandwidth(bl_t, kd), QPSK)
    tail = taus[400:]
    mean = sum(tail) / len(tail)
    var = sum((t - mean) ** 2 for t in tail) / len(tail)
    assert abs(32 * xi - 3.045) < 1e-3
    assert 1.5 <= var / mcrb <= 5.0

History

Kurt H. Mueller and Markus Müller published the method in the IEEE Transactions on Communications in May 1976. They looked for timing functions that a receiver at one sample per symbol can compute from its samples and its decisions, and that become zero at a chosen point of the sampled pulse. Their symmetric function, which equalizes the two pulse samples next to the peak, became the standard symbol-rate timing detector. It is the usual choice in receivers whose equalizer runs at the symbol rate, and its descendants are used for clock recovery in high-speed wireline links.

References

  1. K. H. Mueller and M. Müller, Timing recovery in digital synchronous data receivers, IEEE Transactions on Communications 24(5), 1976, pages 516 to 531, the timing functions computed from one sample per symbol and the decisions, and the function that equalizes the pulse samples one symbol before and after the peak
  2. Umberto Mengali and Aldo N. D'Andrea, Synchronization Techniques for Digital Receivers, Plenum Press, 1997, Chapter 7 (timing recovery in baseband transmission) and Chapter 8 (timing recovery with linear modulations: the decision-directed detectors)
  3. Heinrich Meyr, Marc Moeneclaey and Stefan A. Fechtel, Digital Communication Receivers, Wiley, 1998, Section 5.7 (timing error detectors at the symbol rate)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.qpsk_or_square_qam
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example