Definitionintro
Raised-cosine filter
Also called raised-cosine pulse.
A Nyquist pulse whose spectrum is flat in the middle and falls off as half a cosine period. The roll-off beta sets the excess bandwidth, from 0 (a sinc) to 1 (twice the minimum).
The raised-cosine filter is the pulse whose spectrum is flat up to and then falls to zero at along half a period of a cosine raised above zero. Its folded spectrum is flat, so by the Nyquist ISI criterion it is zero at every nonzero multiple of the symbol period and causes no intersymbol interference. The roll-off factor trades bandwidth for a faster decay in time. In practice the raised cosine is the overall response of a link, split into two root-raised-cosine filters, one at the transmitter and one at the receiver.
Definition
Let be the symbol period and the roll-off factor, and let with . The raised-cosine spectrum is
and the raised-cosine pulse is its inverse Fourier transform,
At the fraction is ; the limit, and the value of there, is . For the pulse is . A raised-cosine filter is a linear filter with impulse response , or in discrete time an FIR filter with taps for , where is the number of samples per symbol and the span in symbols on each side.
Why the formula in time. is the convolution of the rectangle with the half-cosine bump on , which has area . Convolving with a bump of area keeps the flat part at and turns each edge of the rectangle into the integral of the bump, which is the raised cosine edge. In time, convolution becomes a product: the rectangle gives , and the bump gives .
Properties.
- No ISI. and for every integer , because the factor is zero there. (At , which happens for at , the value is too.) In frequency: the edge satisfies for , since , so the fold is the constant .
- Bandwidth. The spectrum is zero for . The baseband bandwidth is ; the bandwidth of the passband signal on a carrier is twice that, . The excess bandwidth over the Nyquist minimum is the fraction .
- Decay. For and large , , which falls like . The sinc () falls only like .
- Energy. By Parseval, .
Computing the pulse
The function below returns the pulse, with the limit at the two singular points. The filter taps are its values at .
RC-PULSE(t, β, T) ▷ the raised-cosine pulse h(t)- 1
u ← t / T - 2
if β > 0 and |2βu| = 1 then - 3
return (π/4) · sinc(1 / (2β)) ▷ the limit at t = ±T/(2β) - 4
return sinc(u) · cos(πβu) / (1 - (2βu)²) RC-TAPS(β, L_s, S) ▷ T = 1, L_s samples per symbol, S symbols on each side- 5
return [RC-PULSE(n / L_s, β, 1) for n = -S·L_s, ..., S·L_s]
The implementation also gives . Its tests check the values on this page, the zeros at for several , the flat fold, the energy in time and in frequency, and the continuity at .
Examples and non-examples
Check values. For and : , , and . For : and . The baseband bandwidth for and is Hz.
The fold at one frequency. For and , the edge runs from to . At , , and its partner . The sum is .
Full roll-off. For the pulse is . Besides the zeros at , it is zero at , and . Zero crossings halfway between the symbols make the timing easy to track, at the cost of twice the minimum bandwidth.
Decay in numbers. The largest over is for , for , and for . A filter truncated to symbols on each side loses little for , and much for the sinc.
Bandwidth of a link. QPSK at million symbols per second with occupies MHz around the carrier and carries Mbit/s, a spectral efficiency of bits/s/Hz.
Non-example: one root-raised-cosine filter. The root-raised-cosine filter has the spectrum . Its folded spectrum is not flat on the edge, so a single RRC pulse has ISI: for , its value at is times its peak. Only the cascade of two RRC filters is a raised cosine.
Non-example: a raised cosine in time. The pulse on , the frequency pulse of LRC continuous-phase modulation, is a raised cosine in time. It is a different object with the same name, and it is not a Nyquist pulse.
Non-example: a Gaussian pulse. The Gaussian filter of Gaussian minimum-shift keying is never zero, so it has ISI at every symbol instant; GMSK accepts this for a compact spectrum.
Related definitions
- Nyquist ISI criterion: the theorem that makes any pulse with a flat fold free of ISI; the raised cosine is its standard example.
- Root-raised-cosine filter: the square root of , used at both ends of a link with a matched filter.
- Pulse shaping: the choice of the transmit pulse, where the raised cosine is the usual target.
- Eye diagram: shows how the eye of a raised-cosine link opens wider in time as grows.
- Sinc interpolation: the case , the ideal low-pass kernel.
- Spectral efficiency: the factor that the excess bandwidth costs.
Code
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
# Part of https://algorithm.tamnd.com/raised-cosine-filter/. The authors are listed in prov/QN0P95.jsonl.
"""The raised-cosine pulse h(t), its spectrum H(f) and the taps of a truncated FIR filter.
T is the symbol period and beta in [0, 1] the roll-off factor. sinc(x) = sin(pi x)/(pi x).
The pulse has h(0) = 1 and h(kT) = 0 for every integer k != 0.
"""
import math
def sinc(x: float) -> float:
"""sin(pi x)/(pi x), with sinc(0) = 1."""
if x == 0:
return 1.0
return math.sin(math.pi * x) / (math.pi * x)
def rc_pulse(t: float, beta: float, period: float = 1.0) -> float:
"""The raised-cosine pulse at time t."""
if not 0 <= beta <= 1:
raise ValueError("beta must be in [0, 1]")
u = t / period # @line L1
if beta > 0 and abs(abs(2 * beta * u) - 1) < 1e-12: # @line L2
return math.pi / 4 * sinc(1 / (2 * beta)) # @line L3
return sinc(u) * math.cos(math.pi * beta * u) / (1 - (2 * beta * u) ** 2) # @line L4
def rc_spectrum(f: float, beta: float, period: float = 1.0) -> float:
"""The raised-cosine spectrum H(f), equal to T on the flat part."""
a = abs(f)
lo = (1 - beta) / (2 * period)
hi = (1 + beta) / (2 * period)
if beta == 0 and a == lo:
return period / 2 # the midpoint of the jump, so that the fold stays flat
if a <= lo:
return period
if a > hi:
return 0.0
return period / 2 * (1 + math.cos(math.pi * period / beta * (a - lo)))
def rc_taps(beta: float, ls: int, span: int) -> list[float]:
"""h(n/ls) for n = -span*ls, ..., span*ls, with T = 1 and ls samples per symbol."""
return [rc_pulse(n / ls, beta) for n in range(-span * ls, span * ls + 1)] # @line L5
test_raised_cosine_filter.py 91 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/raised-cosine-filter/. The authors are listed in prov/QN0P95.jsonl.
import math
from raised_cosine_filter import rc_pulse, rc_spectrum, rc_taps, sinc
def test_check_values() -> None:
assert abs(rc_pulse(0.5, 0.5) - 0.60021) < 5e-6
assert abs(rc_pulse(1.5, 0.5) - (-0.12004)) < 5e-6
assert abs(rc_pulse(0.5, 0.25) - 0.62737) < 5e-6
assert abs(rc_pulse(1.5, 0.25) - (-0.18562)) < 5e-6
assert abs(rc_pulse(0.5, 1.0) - 0.5) < 1e-12
assert abs(rc_pulse(1.0, 0.5)) < 1e-12
# The pulse scales with T: h(t) for period T equals h(t/T) for period 1.
assert abs(rc_pulse(1.0, 0.5, 2.0) - rc_pulse(0.5, 0.5)) < 1e-15
def test_zero_at_nonzero_multiples_of_t() -> None:
for beta in (0.0, 0.1, 0.25, 0.35, 0.5, 0.75, 1.0):
assert rc_pulse(0.0, beta) == 1.0
for k in range(1, 30):
assert abs(rc_pulse(k, beta)) < 1e-12
assert abs(rc_pulse(-k, beta)) < 1e-12
def test_beta_zero_is_sinc() -> None:
for t in (0.1, 0.5, 1.3, 7.7):
assert abs(rc_pulse(t, 0.0) - sinc(t)) < 1e-15
def test_continuity_at_singular_points() -> None:
for beta in (0.2, 0.25, 0.35, 0.5, 1.0):
t0 = 1 / (2 * beta)
at = rc_pulse(t0, beta)
for eps in (1e-6, -1e-6):
assert abs(rc_pulse(t0 + eps, beta) - at) < 1e-5
assert abs(rc_pulse(-t0 + eps, beta) - at) < 1e-5
def test_folded_spectrum_is_flat() -> None:
for beta in (0.0, 0.25, 0.5, 1.0):
for i in range(-50, 51):
f = i / 100
fold = sum(rc_spectrum(f - m, beta) for m in range(-3, 4))
assert abs(fold - 1.0) < 1e-12
assert abs(rc_spectrum(0.4, 0.5) - 0.79389) < 5e-6
assert abs(rc_spectrum(0.6, 0.5) - 0.20611) < 5e-6
assert rc_spectrum(0.5, 0.5) == 0.5
def test_bandwidth() -> None:
assert rc_spectrum(0.625, 0.25) == 0.0
assert rc_spectrum(0.6249, 0.25) > 0.0
def test_energy_in_time_and_frequency() -> None:
for beta in (0.25, 0.5, 1.0):
want = 1 - beta / 4
# Simpson's rule on H^2 over the band.
n = 2000
hi = (1 + beta) / 2
step = 2 * hi / n
s = 0.0
for i in range(n + 1):
w = 1 if i in (0, n) else (4 if i % 2 else 2)
s += w * rc_spectrum(-hi + i * step, beta) ** 2
assert abs(s * step / 3 - want) < 1e-6
# A Riemann sum of h^2 with step 1/16 over |t| <= 100: the pulse is band-limited
# to below 8, so the sum is exact apart from the tail beyond 100.
e = sum(rc_pulse(n / 16, beta) ** 2 for n in range(-1600, 1601)) / 16
assert abs(e - want) < 1e-5
def test_decay() -> None:
def peak(beta: float, k: int) -> float:
return max(abs(rc_pulse(k + i / 1000, beta)) for i in range(1001))
assert abs(peak(0.0, 10) - 0.0303) < 5e-5
assert abs(peak(0.25, 10) - 4.79e-4) < 5e-6
assert abs(peak(0.5, 10) - 2.21e-4) < 5e-6
def test_taps() -> None:
taps = rc_taps(0.25, 8, 8)
assert len(taps) == 2 * 8 * 8 + 1
assert taps[64] == 1.0
assert all(abs(taps[64 + 8 * k]) < 1e-12 for k in range(-8, 9) if k != 0)
assert all(abs(taps[i] - taps[-1 - i]) < 1e-15 for i in range(len(taps)))
assert math.isclose(taps[68], rc_pulse(0.5, 0.25))
References
- John G. Proakis and Masoud Salehi, Digital Communications, fifth edition, McGraw-Hill, 2008, Section 9.2-1 (the raised cosine spectrum, its pulse in time, the roll-off factor and the split of the spectrum between the transmit and the receive filter)
- Robert G. Gallager, Principles of Digital Communication, Cambridge University Press, 2008, Section 6.3.1 (band-edge symmetry and the raised cosine pulse as its standard example)
Where this leads
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 | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag QN0P95 Edit this page History Report an error Markdown