Algorithmcore
Rake receiver
Also called RAKE combiner.
Despreads each resolvable path of a spread-spectrum signal at its own delay, weights each finger output by the conjugate path gain and adds. It is the matched filter to the multipath pulse.
- Solves
- Symbol detection
- Time
- Θ(L N) worst
- Space
- Θ(1) extra
- Where
- L = the number of fingers; N = the number of chips per symbol
- Model
- Real RAM
- Properties
- deterministicexact ml with cyclic prefixmaximal ratio weightsneeds channel estimate
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Robert Price, Paul E. Green Jr., 1958
A rake receiver demodulates a direct-sequence spread-spectrum signal that arrives over several paths with different delays. Each path that is more than about one chip away from the others can be separated by despreading at its own delay. The receiver has one finger for each such path: the finger correlates the received chips with the code shifted by the path delay. A combiner then multiplies each finger output by the conjugate of the path gain and adds them. The result is the matched filter to the whole received pulse, so the receiver collects the energy of all paths instead of treating the late paths as interference. This is the multipath counterpart of maximal ratio combining: MRC combines antennas, and the rake combines delays. Price and Green described it in 1958.
In plain words
A radio signal bounces off buildings and hills, so the receiver hears several copies of it, each a little late and each with its own strength.
A spread-spectrum signal is a long pattern of fast pulses. If the receiver lines up its copy of the pattern with one echo, it hears that echo clearly and the other echoes mostly cancel out, because the pattern does not match itself at other timings.
So the receiver uses several "fingers", one for each strong echo, each lined up with its own echo. Each finger gives a value. The receiver turns each value so that all of them point the same way, gives more weight to the strong echoes and less to the weak ones, and adds them up. The echoes, which would otherwise be a nuisance, now all help.
The problem
One symbol is sent with a code of chips and unit energy, . The channel has resolvable paths with known integer delays (in chips) and known complex gains . With a cyclic prefix, so that there is no interference from the previous symbol, the received block is
with independent noise . The task is to form the statistic for detecting that keeps all the information in about , and to decide . On a real link the delays and gains come from a channel estimate, for example from a pilot channel, and a searcher picks the delays with the most energy.
The algorithm
RAKE(r, c, (d_1, h_1), …, (d_L, h_L))- 1
y ← 0 - 2
for l ← 1 to L do - 3
z_l ← Σ_{n=0}^{N-1} conj(c[(n - d_l) mod N]) · r[n] ▷ finger l: despread at delay d_l - 4
y ← y + conj(h_l) · z_l ▷ maximal ratio weight - 5
return y ▷ for BPSK, decide b̂ = sign(Re y)
Write for the code delayed by chips. Each finger output is , where is the periodic autocorrelation of the code at the shift . A good spreading code has and small for , so each finger sees mainly its own path. The output is
the correlation of with the received pulse . Its signal part is with , and for BPSK the error probability is .
Example
Take the m-sequence code of length , as chips . Its periodic autocorrelation is at shift and elsewhere. The channel has two paths at delays and with gains , and , , no noise.
- The received chips, times , are .
- Finger 1 (delay 0) gives .
- Finger 2 (delay 2) gives .
- The combiner gives , which is .
With noise at dB, the rake gives . A single finger on the strong path has output SNR times and , five times worse.
If the second path has the gain instead, the cross terms are imaginary and drop out of , which becomes . The rake then gives , the same as a single path of unit energy, and the single finger gives .
Correctness
The loop computes , and since the inner product is conjugate-linear in its first argument this equals . Expanding shows that the Gaussian likelihood depends on only through , so is a sufficient statistic, and for BPSK the sign of is the maximum likelihood decision. The noise in is , which gives . For any other weights , the output SNR is , and the Cauchy-Schwarz inequality in the inner product defined by shows that is best. The full proof is in the proofs folder.
Proof: The rake output is the matched filter to the received pulse, and its weights maximize the output SNRfull
The model is one symbol of a direct-sequence signal with a cyclic prefix. The code is with . Write for the code delayed by chips cyclically, . The channel has paths with distinct delays and known gains . The received block is
The finger outputs are , and the rake returns (lines L1 to L5). Let be the matrix with , the periodic autocorrelation of the code at the shift . It is Hermitian and positive semidefinite, with . We assume that it is positive definite, which holds when the shifted codes are linearly independent; for an m-sequence, , whose eigenvalues are and for .
Lemma 1 (the loop computes the defined sum). After the loop, .
Proof. L1 sets . The loop visits each finger once (L2). At finger , L3 computes by its definition and L4 adds . By induction on the number of fingers visited, after fingers is the sum over those fingers. After all , it is the full sum, which L5 returns.
Lemma 2 (matched filter). .
Proof. The inner product is conjugate-linear in . So
Lemma 3 (the statistic is sufficient). Given , the likelihood of a symbol value depends on only through . For BPSK with and equal priors, the maximum likelihood decision is the sign of .
Proof. The density of given is . Expand the norm:
The first term does not depend on , and the others depend on only through . For , , so the likelihood is larger for exactly when .
Lemma 4 (output statistics). , and with . For BPSK, the error probability of the decision in Lemma 3 is
Proof. . By Lemma 2, . The term is a fixed linear combination of independent samples, so it is circularly symmetric Gaussian with variance ; its real part has variance . Given , an error occurs when , with probability . The case is symmetric.
Lemma 5 (maximal ratio weights are best). For any nonzero weights , the combiner has output SNR
with equality if and only if is a nonzero multiple of .
Proof. The vector of finger outputs is , where has covariance . So has signal part and noise variance , which gives the formula for . Since is positive definite, is an inner product, and the Cauchy-Schwarz inequality gives , with equality exactly when and are parallel. Dividing by gives the bound.
Theorem. The rake receiver returns , the output of the filter matched to the received pulse. The sign of is the maximum likelihood BPSK decision, with error probability , and no other choice of finger weights gives a larger output SNR. When the shifted codes are orthogonal (), , the SNR of maximal ratio combining over independent branches.
Proof. Lemmas 1 to 5.
Cost. Each finger computes one correlation of products (L3) and one multiply-add (L4). The total is operations per symbol and space beyond the input.
Complexity
In the real RAM model, each finger does complex multiply-adds (L3) and one more (L4). The total is per symbol, with extra space. A matched filter to also costs per symbol once is built, but costs to form and changes whenever the channel changes. The fingers need only the code, the delays and the gains.
Properties
- Matched filter to the multipath pulse. The rake output equals exactly, so it is optimal for one symbol when there is no interference between symbols.
- Maximal ratio weights. Weighting finger by maximizes the output SNR over all linear combinations of the finger outputs.
- Orthogonal codes give MRC. If the shifted codes are orthogonal (), the output SNR is , the same as maximal ratio combining of antennas. With independent Rayleigh paths this gives a diversity order of .
- Cross terms. With a real code, the term can raise or lower the energy, depending on the phases of the paths. It goes to zero as grows for an m-sequence, since .
- Needs the channel. The weights need the gains and the delays. Errors in them lower the SNR but do not change the structure of the receiver.
Variants and improvements
- Selective and partial rake. Use only the strongest paths, or the first paths, to save hardware. The loss is the energy of the unused paths.
- Equal gain combining. Co-phase the fingers but give them equal weights. It needs only the phases, not the amplitudes.
- Generalized rake (G-RAKE). In interference-limited links, weight the fingers by , where is the covariance of interference plus noise across fingers, and place extra fingers at delays with no path. It whitens colored interference.
- Chip-level equalization. In the WCDMA downlink, a linear equalizer before despreading restores the orthogonality of the OVSF codes that multipath destroys. The rake does not restore it.
- Rake with soft handover. Fingers can be assigned to paths from different base stations that send the same data, so the rake also combines across cells.
When to use it
Use a rake receiver for direct-sequence signals whose delay spread is larger than a chip, so that several paths are resolvable, and whose spreading factor is large enough that the code keeps the fingers apart. This was the case for IS-95 and WCDMA. When the delay spread covers many chips and the spreading factor is small, the interference between symbols and between paths grows, and an equalizer or OFDM with a cyclic prefix is the better choice.
Pitfalls
- Paths closer than one chip. Two paths less than about one chip apart cannot be separated by despreading. A single finger then sees their sum, which fades like one Rayleigh path; see multipath fading.
- Ignoring the cross terms. For short codes, is not small, and the SNR is , not . Formulas that assume orthogonal paths are then wrong by a visible amount: against in the example.
- Intersymbol interference. Without a cyclic prefix, a path with delay brings chips of the previous symbol into the window. For long spreading codes this acts like noise; for short codes and a large delay spread it does not, and the error rate is worse than the formula.
- Stale channel estimates. On a fast fading channel, weights from old estimates can add the paths with the wrong phases. Track the gains at least as fast as the coherence time of the channel.
- Finger management. Paths appear and disappear. A searcher must keep looking for new delays, or the fingers end up on weak paths.
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.
# SPDX-License-Identifier: MIT
# Shared helper of the communications pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Complex baseband tools for the communications pages.
Vectors are lists of complex numbers. Matrices are lists of rows. The
functions here are plain building blocks: small linear algebra, convolution,
the DFT as a direct sum, the Gaussian Q function, dB conversion, complex
Gaussian noise and the Wilson score interval. No page algorithm (equalizer,
estimator, synchronizer, detector, precoder, demapper or power allocation)
lives in this file.
Conventions (prompts of the communications area):
- dft is X[k] = sum_n x[n] e^(-j 2 pi k n / N) with no factor; idft has 1/N.
- udft and uidft are the unitary pair, with 1/sqrt(N) on both sides.
- qfunc(x) = 0.5 erfc(x / sqrt(2)); it never computes 1 - Phi(x).
- cn(rng, var) draws CN(0, var): real and imaginary parts are independent
with variance var / 2 each, so E|w|^2 = var.
"""
import cmath
import math
import random
# ---------------------------------------------------------------- vectors and matrices
def zeros(rows: int, cols: int | None = None) -> list:
"""A zero vector of length rows, or a rows by cols zero matrix."""
if cols is None:
return [0j] * rows
return [[0j] * cols for _ in range(rows)]
def eye(n: int) -> list[list[complex]]:
"""The n by n identity matrix."""
return [[1 + 0j if i == k else 0j for k in range(n)] for i in range(n)]
def add(a: list, b: list) -> list:
"""Elementwise a + b for two vectors or two matrices of the same shape."""
if len(a) != len(b):
raise ValueError("shapes differ")
if a and isinstance(a[0], list):
return [add(r, s) for r, s in zip(a, b)]
return [x + y for x, y in zip(a, b)]
def sub(a: list, b: list) -> list:
"""Elementwise a - b for two vectors or two matrices of the same shape."""
if len(a) != len(b):
raise ValueError("shapes differ")
if a and isinstance(a[0], list):
return [sub(r, s) for r, s in zip(a, b)]
return [x - y for x, y in zip(a, b)]
def scale(c: complex, a: list) -> list:
"""The scalar c times a vector or a matrix."""
if a and isinstance(a[0], list):
return [scale(c, r) for r in a]
return [c * x for x in a]
def matmul(a: list[list[complex]], b: list[list[complex]]) -> list[list[complex]]:
"""The matrix product a b."""
if not a or not b or len(a[0]) != len(b):
raise ValueError("inner dimensions differ")
cols = list(zip(*b))
return [[sum(x * y for x, y in zip(row, col)) for col in cols] for row in a]
def matvec(a: list[list[complex]], x: list[complex]) -> list[complex]:
"""The matrix times vector product a x."""
if a and len(a[0]) != len(x):
raise ValueError("inner dimensions differ")
return [sum(p * q for p, q in zip(row, x)) for row in a]
def herm(a: list) -> list:
"""The conjugate transpose of a matrix. A vector gives its conjugate."""
if a and isinstance(a[0], list):
return [[complex(a[i][k]).conjugate() for i in range(len(a))] for k in range(len(a[0]))]
return [complex(x).conjugate() for x in a]
def dot(x: list[complex], y: list[complex]) -> complex:
"""The inner product x^H y = sum of conj(x_i) y_i."""
if len(x) != len(y):
raise ValueError("lengths differ")
return sum(complex(p).conjugate() * q for p, q in zip(x, y))
def norm2(x: list) -> float:
"""The squared Euclidean norm sum |x_i|^2 (squared Frobenius norm for a matrix)."""
if x and isinstance(x[0], list):
return sum(norm2(r) for r in x)
return sum(abs(v) ** 2 for v in x)
# ---------------------------------------------------------------- linear systems
def _lu(a: list[list[complex]]) -> tuple[list[list[complex]], list[int], int]:
"""LU factorization with partial pivoting. Returns (lu, perm, sign)."""
n = len(a)
if any(len(r) != n for r in a):
raise ValueError("matrix is not square")
m = [[complex(v) for v in r] for r in a]
perm = list(range(n))
sign = 1
for k in range(n):
p = max(range(k, n), key=lambda i: abs(m[i][k]))
if abs(m[p][k]) == 0.0:
raise ValueError("matrix is singular")
if p != k:
m[k], m[p] = m[p], m[k]
perm[k], perm[p] = perm[p], perm[k]
sign = -sign
for i in range(k + 1, n):
f = m[i][k] / m[k][k]
m[i][k] = f
if f != 0:
rk, ri = m[k], m[i]
for c in range(k + 1, n):
ri[c] -= f * rk[c]
return m, perm, sign
def _lu_solve(lu: list[list[complex]], perm: list[int], b: list[complex]) -> list[complex]:
n = len(lu)
y = [complex(b[perm[i]]) for i in range(n)]
for i in range(n):
for c in range(i):
y[i] -= lu[i][c] * y[c]
for i in range(n - 1, -1, -1):
for c in range(i + 1, n):
y[i] -= lu[i][c] * y[c]
y[i] /= lu[i][i]
return y
def solve(a: list[list[complex]], b: list) -> list:
"""Solve a x = b by Gaussian elimination with partial pivoting.
b is a vector, or a matrix whose columns are right-hand sides.
Raises ValueError if a is singular.
"""
lu, perm, _ = _lu(a)
if b and isinstance(b[0], list):
cols = [list(c) for c in zip(*b)]
xs = [_lu_solve(lu, perm, c) for c in cols]
return [list(r) for r in zip(*xs)]
if len(b) != len(a):
raise ValueError("lengths differ")
return _lu_solve(lu, perm, b)
def inv(a: list[list[complex]]) -> list[list[complex]]:
"""The inverse of a square matrix."""
return solve(a, eye(len(a)))
def det(a: list[list[complex]]) -> complex:
"""The determinant of a square matrix (0 for a singular matrix)."""
try:
lu, _, sign = _lu(a)
except ValueError as e:
if "singular" in str(e):
return 0j
raise
d = complex(sign)
for i in range(len(lu)):
d *= lu[i][i]
return d
def cholesky(a: list[list[complex]]) -> list[list[complex]]:
"""The lower triangular L with a = L L^H, for a Hermitian positive definite a.
Raises ValueError if a is not positive definite (to rounding).
"""
n = len(a)
low = zeros(n, n)
for i in range(n):
for k in range(i + 1):
s = complex(a[i][k]) - sum(low[i][c] * low[k][c].conjugate() for c in range(k))
if i == k:
if s.real <= 0.0:
raise ValueError("matrix is not positive definite")
low[i][i] = complex(math.sqrt(s.real))
else:
low[i][k] = s / low[k][k].real
return low
# ---------------------------------------------------------------- convolution and the DFT
def conv(a: list[complex], b: list[complex]) -> list[complex]:
"""Linear convolution, of length len(a) + len(b) - 1."""
if not a or not b:
return []
out = [0j] * (len(a) + len(b) - 1)
for i, x in enumerate(a):
for k, y in enumerate(b):
out[i + k] += x * y
return out
def cconv(a: list[complex], b: list[complex], n: int | None = None) -> list[complex]:
"""Circular convolution of length n (default: the longer length).
Both inputs are padded with zeros to length n, or must not be longer than n.
"""
if n is None:
n = max(len(a), len(b))
if len(a) > n or len(b) > n:
raise ValueError("input longer than n")
out = [0j] * n
for i, x in enumerate(a):
for k, y in enumerate(b):
out[(i + k) % n] += x * y
return out
def _twiddles(n: int, sign: int) -> list[complex]:
return [cmath.exp(sign * 2j * math.pi * t / n) for t in range(n)]
def dft(x: list[complex]) -> list[complex]:
"""X[k] = sum over n of x[n] e^(-j 2 pi k n / N), as a direct O(N^2) sum."""
n = len(x)
w = _twiddles(n, -1)
return [sum(x[t] * w[(k * t) % n] for t in range(n)) for k in range(n)]
def idft(xf: list[complex]) -> list[complex]:
"""x[n] = (1/N) sum over k of X[k] e^(j 2 pi k n / N), the inverse of dft."""
n = len(xf)
w = _twiddles(n, 1)
return [sum(xf[k] * w[(k * t) % n] for k in range(n)) / n for t in range(n)]
def udft(x: list[complex]) -> list[complex]:
"""The unitary DFT: dft(x) / sqrt(N)."""
s = 1.0 / math.sqrt(len(x)) if x else 1.0
return [v * s for v in dft(x)]
def uidft(xf: list[complex]) -> list[complex]:
"""The unitary inverse DFT: sqrt(N) idft(X), the inverse of udft."""
s = math.sqrt(len(xf)) if xf else 1.0
return [v * s for v in idft(xf)]
# ---------------------------------------------------------------- Q function and dB
def qfunc(x: float) -> float:
"""Q(x) = P(Z > x) for a standard normal Z, computed as 0.5 erfc(x / sqrt(2))."""
return 0.5 * math.erfc(x / math.sqrt(2.0))
def qinv(p: float) -> float:
"""The x with Q(x) = p, for 0 < p < 1, by bisection on Q (which decreases)."""
if not 0.0 < p < 1.0:
raise ValueError("p must be in (0, 1)")
lo, hi = -40.0, 40.0
for _ in range(200):
mid = 0.5 * (lo + hi)
if qfunc(mid) > p:
lo = mid
else:
hi = mid
if hi - lo <= 1e-15 * max(1.0, abs(mid)):
break
return 0.5 * (lo + hi)
def db(x: float) -> float:
"""10 log10(x), for a ratio of powers or energies."""
return 10.0 * math.log10(x)
def undb(d: float) -> float:
"""10^(d / 10), the inverse of db."""
return 10.0 ** (d / 10.0)
# ---------------------------------------------------------------- noise and statistics
def cn(rng: random.Random, var: float) -> complex:
"""One sample of CN(0, var): independent real and imaginary parts of variance var / 2."""
s = math.sqrt(var / 2.0)
return complex(rng.gauss(0.0, s), rng.gauss(0.0, s))
def awgn(rng: random.Random, x: list[complex], n0: float) -> list[complex]:
"""x plus independent CN(0, n0) noise on each sample."""
return [v + cn(rng, n0) for v in x]
def wilson(k: int, n: int, z: float = 3.29) -> tuple[float, float]:
"""The Wilson score interval for k successes in n trials (z = 3.29 is about 0.999 two-sided)."""
if n <= 0 or not 0 <= k <= n:
raise ValueError("need 0 <= k <= n and n > 0")
p = k / n
z2 = z * z
den = 1.0 + z2 / n
mid = (p + z2 / (2 * n)) / den
half = z * math.sqrt(p * (1 - p) / n + z2 / (4 * n * n)) / den
return max(0.0, mid - half), min(1.0, mid + half)
rake_receiver.py 99 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/rake-receiver/. The authors are listed in prov/MRC17X.jsonl.
"""A rake receiver for one direct-sequence symbol on a known multipath channel.
Model (one symbol, with a cyclic prefix so that the delays are cyclic):
r[n] = sqrt(Es) b sum over l of h[l] c[(n - d[l]) mod N] + w[n], n = 0, ..., N - 1,
where c is the chip code with sum |c[n]|^2 = 1, b the symbol, h[l] and d[l]
the gain and the delay (in chips) of path l, and w[n] ~ CN(0, N0).
Finger l despreads at delay d[l]: z[l] = sum over n of conj(c[(n - d[l]) mod N]) r[n].
The combiner forms y = sum over l of conj(h[l]) z[l] (maximal ratio weights).
"""
import math
import random
from cbb import cn, qfunc
def shifted(c: list[complex], d: int) -> list[complex]:
"""The code delayed by d chips, cyclically: (c[(n - d) mod N])_n."""
n = len(c)
return [c[(k - d) % n] for k in range(n)]
def rake(r: list[complex], c: list[complex], delays: list[int], gains: list[complex]) -> complex:
"""The rake output y = sum over fingers of conj(h[l]) times the despread value at delay d[l]."""
if len(delays) != len(gains):
raise ValueError("one gain per delay")
n = len(c)
y = 0j # @line L1
for d, h in zip(delays, gains): # @line L2
z = sum(c[(k - d) % n].conjugate() * r[k] for k in range(n)) # @line L3
y += h.conjugate() * z # @line L4
return y # @line L5
def composite(c: list[complex], delays: list[int], gains: list[complex]) -> list[complex]:
"""The received pulse g = sum over l of h[l] times the code delayed by d[l]."""
n = len(c)
g = [0j] * n
for d, h in zip(delays, gains):
for k, v in enumerate(shifted(c, d)):
g[k] += h * v
return g
def code_gram(c: list[complex], delays: list[int]) -> list[list[complex]]:
"""R[l][m] = sum over n of conj(c[n - d[l]]) c[n - d[m]], the correlations of the finger codes."""
cs = [shifted(c, d) for d in delays]
return [[sum(x.conjugate() * y for x, y in zip(a, b)) for b in cs] for a in cs]
def energy(c: list[complex], delays: list[int], gains: list[complex]) -> float:
"""||g||^2 = h^H R h, the energy of the received pulse per unit Es."""
rr = code_gram(c, delays)
total = 0j
for i, hi in enumerate(gains):
for k, hk in enumerate(gains):
total += hi.conjugate() * rr[i][k] * hk
return total.real
def output_snr(c: list[complex], delays: list[int], gains: list[complex], weights: list[complex], es: float, n0: float) -> float:
"""Es |a^H R h|^2 / (N0 a^H R a): the SNR at the combiner output for weights a."""
rr = code_gram(c, delays)
num = sum(weights[i].conjugate() * rr[i][k] * gains[k] for i in range(len(gains)) for k in range(len(gains)))
den = sum(weights[i].conjugate() * rr[i][k] * weights[k] for i in range(len(gains)) for k in range(len(gains)))
return es * abs(num) ** 2 / (n0 * den.real)
def bpsk_error_probability(c: list[complex], delays: list[int], gains: list[complex], es: float, n0: float) -> float:
"""Pb = Q(sqrt(2 Es h^H R h / N0)) for BPSK with the rake receiver."""
return qfunc(math.sqrt(2.0 * es * energy(c, delays, gains) / n0))
def receive(rng: random.Random, b: complex, c: list[complex], delays: list[int], gains: list[complex], es: float, n0: float) -> list[complex]:
"""One received block of N chips, with noise CN(0, N0) per chip (N0 = 0 for no noise)."""
g = composite(c, delays, gains)
a = math.sqrt(es) * b
if n0 == 0:
return [a * v for v in g]
return [a * v + cn(rng, n0) for v in g]
def mseq_code(exps: list[int]) -> list[complex]:
"""One period of an m-sequence as unit-energy chips: bit 0 -> +1/sqrt(N), bit 1 -> -1/sqrt(N)."""
n = max(exps)
s = [1] + [0] * (n - 1)
taps = [i for i in exps if i < n]
while len(s) < (1 << n) - 1:
k = len(s) - n
bit = 0
for i in taps:
bit ^= s[k + i]
s.append(bit)
scale = 1.0 / math.sqrt(len(s))
return [complex((1 - 2 * v) * scale) for v in s]
test_rake_receiver.py 75 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/rake-receiver/. The authors are listed in prov/MRC17X.jsonl.
import math
import random
from cbb import cn, dot, wilson
from rake_receiver import bpsk_error_probability, code_gram, composite, energy, mseq_code, output_snr, rake, receive
C7 = mseq_code([3, 1, 0])
C31 = mseq_code([5, 2, 0])
def test_check_values_length_seven() -> None:
assert abs(sum(abs(v) ** 2 for v in C7) - 1) < 1e-12
rr = code_gram(C7, [0, 2])
assert abs(rr[0][0] - 1) < 1e-12 and abs(rr[0][1] + 1 / 7) < 1e-12
assert abs(energy(C7, [0, 2], [0.8, 0.6]) - (1 - 0.96 / 7)) < 1e-12
assert abs(energy(C7, [0, 2], [0.8, 0.6j]) - 1) < 1e-12
def test_rake_is_the_matched_filter_to_the_received_pulse() -> None:
rng = random.Random(1)
for _ in range(50):
n_paths = rng.randint(1, 4)
delays = rng.sample(range(31), n_paths)
gains = [cn(rng, 1.0) for _ in range(n_paths)]
r = [cn(rng, 1.0) for _ in range(31)]
g = composite(C31, delays, gains)
assert abs(rake(r, C31, delays, gains) - dot(g, r)) < 1e-9
def test_noiseless_symbols_are_recovered() -> None:
rng = random.Random(2)
for _ in range(50):
delays = rng.sample(range(31), 3)
gains = [cn(rng, 1.0) for _ in range(3)]
b = rng.choice((-1, 1))
r = receive(rng, b, C31, delays, gains, 1.0, 0.0)
y = rake(r, C31, delays, gains)
assert abs(y - b * energy(C31, delays, gains)) < 1e-9
def test_maximal_ratio_weights_maximize_the_output_snr() -> None:
rng = random.Random(3)
delays = [0, 1, 5]
gains = [0.9, 0.5 - 0.3j, 0.2j]
best = output_snr(C7, delays, gains, gains, 1.0, 1.0)
assert abs(best - energy(C7, delays, gains)) < 1e-12
for _ in range(500):
a = [cn(rng, 1.0) for _ in range(3)]
assert output_snr(C7, delays, gains, a, 1.0, 1.0) <= best + 1e-12
one_finger = output_snr(C7, delays, gains, [1, 0, 0], 1.0, 1.0)
assert one_finger < best
def test_bit_error_rate_matches_the_formula() -> None:
rng = random.Random(4)
delays, gains = [0, 2], [0.8, 0.6]
es, n0 = 1.0, 1.0
pb = bpsk_error_probability(C7, delays, gains, es, n0)
errors = trials = 0
while errors < 150:
b = rng.choice((-1, 1))
y = rake(receive(rng, b, C7, delays, gains, es, n0), C7, delays, gains)
trials += 1
if (1 if y.real >= 0 else -1) != b:
errors += 1
lo, hi = wilson(errors, trials)
assert lo <= pb <= hi
def test_formula_value() -> None:
pb = bpsk_error_probability(C7, [0, 2], [0.8, 0.6], 1.0, 1.0)
assert abs(pb - 0.5 * math.erfc(math.sqrt(1 - 0.96 / 7))) < 1e-15
History
Robert Price and Paul Green Jr. described the Rake system in the Proceedings of the IRE in 1958. It sent wideband signals over a multipath HF channel and used a tapped delay line to measure the channel and to weight and add the paths; the name refers to the taps of the delay line, which look like the teeth of a garden rake. With the cellular CDMA systems of the 1990s, IS-95 and later WCDMA, the rake receiver became the standard receiver for direct-sequence signals in mobile phones and base stations.
References
- R. Price and P. E. Green, Jr., A communication technique for multipath channels, Proceedings of the IRE 46(3), 1958, pp. 555 to 570 (the Rake system, its tapped delay line and the weighting of the paths by their measured gains)
- John G. Proakis and Masoud Salehi, Digital Communications, 5th edition, McGraw-Hill, 2008, The chapter on fading channels (the RAKE demodulator for frequency-selective channels and its error probability)
- David Tse and Pramod Viswanath, Fundamentals of Wireless Communication, Cambridge University Press, 2005, The chapter on diversity (frequency diversity, direct-sequence spread spectrum and the rake receiver)
- Andrew J. Viterbi, CDMA, Principles of Spread Spectrum Communication, Addison-Wesley, 1995, The material on multipath diversity reception in a direct-sequence CDMA receiver
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag MRC17X Edit this page History Report an error Markdown