Definitionadvanced
Kasami sequences
Also called Kasami codes.
Binary sequence families from an m-sequence and its decimations. The small set has 2^(n/2) sequences of period 2^n - 1 and largest correlation 1 + 2^(n/2), the least possible for binary sequences.
Kasami sequences are binary sequence families of period , for even , made by adding an m-sequence to the shifts of one or two decimations of . The small set has sequences, and every off-peak autocorrelation and every cross-correlation in it takes one of the three values , and , so the largest magnitude is , about . The large set, for , contains a Gold family and many more sequences, with the Gold bound as its largest correlation. The small set is optimal for binary sequences in the sense of Sarwate and Pursley 1980: the Welch bound and the fact that binary correlations of odd length are odd integers force for any binary sequences of period , and the small set reaches that value. It does not meet the real-valued Welch bound with equality. The construction comes from Kasami's 1966 report on the weight distributions of some cyclic codes.
Definition
Use the notation of the Gold sequences page: bit sequences of period , the shift , the decimation , the periodic correlation and the figure of merit over all pairs and shifts except the peaks.
Small set. Let be even, an m-sequence of degree and period , and . The decimation is not an m-sequence of degree : since divides , has period , and it is an m-sequence of degree repeated times. The small Kasami set is
with sequences of period . Every off-peak autocorrelation and every cross-correlation of takes a value in , so (Sarwate and Pursley 1980, the section on Kasami sequences). Each member satisfies a linear recurrence of degree , the product of the polynomials of and .
Large set. For , let with , so that is a preferred pair, and as above. The large set is the Gold family together with the sums , and for and . It has sequences, and its correlations take values in , so , the same as the Gold family it contains (Sarwate and Pursley 1980).
Optimality of the small set. Let , so . The sequence form of the Welch bound says that sequences of length and energy have . Then : squaring and dividing by , this is , which reduces to . A correlation of two sequences of odd length is minus twice a count, so it is odd. The odd numbers above start at , so every binary family of sequences of period has , and the small Kasami set meets this. The real bound itself is strictly smaller than .
KASAMI-SMALL(u) ▷ u an m-sequence of even degree n, N = 2^n - 1- 1
w ← u[2^{n/2} + 1] ▷ decimation: w[k] = u[(2^{n/2} + 1) k mod N] - 2
F ← [u] - 3
for τ ← 0 to 2^{n/2} - 2 do - 4
append u ⊕ T^τ w to F return FTHETA-MAX(F)- 5
return the largest |θ_{a,b}(τ)| over a, b in F and τ, except a = b with τ = 0
The construction costs bit operations in the word RAM model, and the direct check of costs .
Examples and non-examples
Degree 4. With from () and , the decimation has period . The small set has sequences of period . Over all ordered pairs and shifts except the peaks, the correlation is in cases, in cases and in cases. So . The Welch bound for and is ; the least odd integer at or above it is .
Degree 6. With from , has period . The small set has sequences of period , with correlation values , and and . The Welch bound is , so is the least possible odd value. A Gold family of degree 6 has sequences and . The small Kasami set trades sequences for half the largest correlation.
Degree 8. With from , the small set has sequences of period and , against a Welch bound of . The ratio of to the bound is , and for , and ; it goes to as grows.
Large set, degree 6. With and , the large set has sequences of period , and its correlations lie in , so .
Non-example: odd . For odd , is not an integer and has no factor . The small set does not exist; use a Gold family.
Non-example: decimating by a number coprime to . If , then is again an m-sequence of period , not a short sequence, and adding it to gives a Gold-like family only for the preferred values of . The Kasami step needs the short period that comes from .
Related definitions
- Gold sequences have about sequences and near or . The small Kasami set has about sequences and near . The large Kasami set has about sequences with the Gold value of .
- The Welch bound is the reference for optimality. Complex sequence families, such as sets of Zadoff-Chu sequences of prime length, can do better than any binary family.
- The sums of members of the small set lie in the cyclic code of length and dimension spanned by the shifts of and . A correlation value belongs to a codeword of weight , so the three values correspond to the three nonzero weights and . Kasami's 1966 report found the weight distributions of this class of cyclic codes.
- Code-division multiple access uses such families as user signatures. IS-95, for example, uses long m-sequences and Walsh codes instead.
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/kasami-sequences/. The authors are listed in prov/H5NT6J.jsonl.
"""The small set of Kasami sequences, with integer correlations.
A polynomial over GF(2) is the list of its exponents, for example [6, 1, 0]
for x^6 + x + 1. For even n, let u be an m-sequence of period N = 2^n - 1 and
w = u decimated by s = 2^(n/2) + 1, which has period 2^(n/2) - 1. The small
Kasami set is u together with u XOR (w shifted by t) for
t = 0, ..., 2^(n/2) - 2: 2^(n/2) sequences of period N.
"""
import math
def mseq(exps: list[int], state: list[int] | None = None) -> list[int]:
"""One period of the recurrence s[k + n] = XOR over the exponents i < n of s[k + i]."""
n = max(exps)
s = list(state) if state is not None else [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)
return s
def decimate(s: list[int], q: int) -> list[int]:
"""The sequence s[q k mod N], k = 0, ..., N - 1."""
n = len(s)
return [s[(q * k) % n] for k in range(n)]
def least_period(s: list[int]) -> int:
"""The least p > 0 with s[k] = s[(k + p) mod N] for all k."""
n = len(s)
for p in range(1, n + 1):
if n % p == 0 and all(s[k] == s[(k + p) % n] for k in range(n)):
return p
return n
def kasami_small(u: list[int]) -> list[list[int]]:
"""The small Kasami set of an m-sequence u of even degree n (as bit lists)."""
big = len(u)
n = (big + 1).bit_length() - 1
if (1 << n) - 1 != big or n % 2:
raise ValueError("u must have period 2^n - 1 with n even")
s = (1 << (n // 2)) + 1
w = decimate(u, s) # @line L1
fam = [list(u)] # @line L2
for t in range((1 << (n // 2)) - 1): # @line L3
fam.append([u[k] ^ w[(k + t) % big] for k in range(big)]) # @line L4
return fam
def xcorr(a: list[int], b: list[int], t: int) -> int:
"""Periodic correlation sum over k of (-1)^(a[k] XOR b[k + t])."""
n = len(a)
return n - 2 * sum(a[k] ^ b[(k + t) % n] for k in range(n))
def max_correlation(fam: list[list[int]]) -> int:
"""theta_max over all pairs and shifts, except the peaks of a sequence with itself at shift 0."""
best = 0
for i, a in enumerate(fam):
for j in range(i, len(fam)):
for t in range(len(a)):
if i == j and t == 0:
continue
best = max(best, abs(xcorr(a, fam[j], t))) # @line L5
return best
def welch_sequence_bound(m: int, n: int) -> float:
"""The Welch bound N sqrt((M - 1) / (M N - 1)) on theta_max for M sequences of length N and energy N."""
return n * math.sqrt((m - 1) / (m * n - 1))
test_kasami_sequences.py 70 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/kasami-sequences/. The authors are listed in prov/H5NT6J.jsonl.
import math
from kasami_sequences import decimate, kasami_small, least_period, max_correlation, mseq, welch_sequence_bound, xcorr
PRIMITIVE = {4: [4, 1, 0], 6: [6, 1, 0], 8: [8, 4, 3, 2, 0]}
def brute_xcorr(a: list[int], b: list[int], t: int) -> int:
n = len(a)
return sum((1 - 2 * a[k]) * (1 - 2 * b[(k + t) % n]) for k in range(n))
def all_values(fam: list[list[int]]) -> set[int]:
out = set()
for i, a in enumerate(fam):
for j, b in enumerate(fam):
for t in range(len(a)):
if i != j or t != 0:
out.add(xcorr(a, b, t))
return out
def test_xcorr_against_plus_minus_one_sum() -> None:
fam = kasami_small(mseq(PRIMITIVE[4]))
for a in fam:
for b in fam:
for t in range(15):
assert xcorr(a, b, t) == brute_xcorr(a, b, t)
def test_decimated_sequence_has_short_period() -> None:
for n, f in PRIMITIVE.items():
w = decimate(mseq(f), (1 << (n // 2)) + 1)
assert least_period(w) == (1 << (n // 2)) - 1
def test_three_values_and_bound() -> None:
for n in (4, 6):
fam = kasami_small(mseq(PRIMITIVE[n]))
half = 1 << (n // 2)
assert len(fam) == half
assert len({tuple(s) for s in fam}) == half
assert all_values(fam) == {-1, -1 - half, -1 + half}
assert max_correlation(fam) == 1 + half
def test_degree_eight_bound() -> None:
fam = kasami_small(mseq(PRIMITIVE[8]))
assert len(fam) == 16 and max_correlation(fam) == 17
def test_optimal_against_welch_for_binary_sequences() -> None:
# Correlations of binary sequences of odd length are odd integers, so
# theta_max >= the least odd integer at or above the Welch bound.
for n in (4, 6, 8, 10, 12):
big = (1 << n) - 1
m = 1 << (n // 2)
w = welch_sequence_bound(m, big)
least_odd = math.ceil(w)
if least_odd % 2 == 0:
least_odd += 1
assert least_odd == 1 + m
assert w < 1 + m # the bound itself is not met with equality
def test_check_values_degree_six() -> None:
assert abs(welch_sequence_bound(8, 63) - 7.431998) < 1e-6
References
- Tadao Kasami, Weight Distribution Formula for Some Class of Cyclic Codes, Coordinated Science Laboratory, University of Illinois, Report R-285, April 1966 (doi:10.21236/ad0632574), The whole report (the weight distribution of the cyclic codes whose codewords give the Kasami sequences)
- Dilip V. Sarwate and Michael B. Pursley, Crosscorrelation properties of pseudorandom and related sequences, Proceedings of the IEEE 68(5), 1980, pp. 593 to 619 (the sections on the small and the large sets of Kasami sequences and their comparison with the Welch bound)
- Lloyd R. Welch, Lower bounds on the maximum cross correlation of signals, IEEE Transactions on Information Theory 20(3), 1974, pp. 397 to 399 (the bound that the small Kasami set is compared with)
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 H5NT6J Edit this page History Report an error Markdown