cs.DSNov 1, 2026

Efficient Lempel-Ziv Prediction with the Run-Length BWT

Authors: Ohad Avnery

Organizations: Computational Rational Agents Laboratory (CORAL)

Abstract

Lempel-Ziv Plurality (LZP) is an algorithm of Kosoy that predicts the next symbol of a string by using its Lempel-Ziv factorization, and makes at most O(zlog⁡n)O(z\log n) mistakes on every string of length nn with zz LZ77 phrases. We give efficient online implementations of LZP and of a new variant of it. Our first implementation maintains a run-length encoded Burrows-Wheeler transform (RLBWT) of the reversed history. It implements LZP, uses O(zlog⁡zlog⁡2n)O(z\log z\log^2 n) bits, and has worst-case update and prediction times O(log⁡z+log⁡log⁡n)O(\log z+\log\log n) and O(σ(log⁡z+log⁡log⁡n))O(σ(\log z+\log\log n)), respectively, where σσ is the size of the alphabet. This is an exponential improvement over Kosoy's implementation, whose update time is O(zlog⁡7n)O(z\log^7 n). We then introduce the Lempel-Ziv Majority (LZM) predictor, which has the same mistake bound and update time, and predicts in O(1)O(1) time independently of σσ. These two predictors accept new symbols at any time, without knowing the alphabet in advance. For an alphabet known in advance, a different data structure gives O(σ(1+log⁡z/log⁡log⁡n))O(σ(1+\log z/\log\log n)) time per symbol, which is constant when σ=O(1)σ=O(1) and z=polylog(n)z=\mathrm{polylog}(n).

Figures & tables

Explore similar work

Sep 17, 2026

Stringological sequence prediction III: layered ziplines and a tradeoff between efficiency and expressivity

In previous papers, we began the study of sequence prediction algorithms adapted to stringological word complexity measures. In particular, we defined a complexity measure called Arithmetic Repetition Complexity (ARC) which admits a polynomial-time prediction algorithm with a mistake bound quasilinear in the complexity. Here, we show a weaker complexity measure related to ARC that admits an especially efficient prediction algorithm: an algorithm that runs in quasilinear time and polylog space for appropriate highly-structured sequences. The complexity measure is defined via a restricted class of "zipline programs" (a variant of straight-line programs), which we call layered. We thus get a less expressive measure with a more efficient algorithm (compared to our results for ARC), demonstrating a possible tradeoff.
Mar 27, 2026

Stringological sequence prediction I: efficient algorithms for predicting highly repetitive sequences

We propose novel algorithms for sequence prediction based on ideas from stringology. These algorithms are time and space efficient and satisfy mistake bounds related to particular stringological complexity measures of the sequence. In this work (the first in a series) we focus on two such measures: (i) the size of the smallest straight-line program that produces the sequence, and (ii) the number of states in the minimal automaton that can compute any symbol in the sequence when given its position in base k as input. These measures are interesting because multiple rich classes of sequences studied in combinatorics of words (automatic sequences, morphic sequences, characteristic words) have low complexity and hence high predictability in this sense.
Aug 20, 2026

A Layered Simplex Architecture for Large Alphabets

A learning architecture induces a prior over its expressible models. Recent work links architectural success to a broad complexity spectrum: model probabilities spanning many orders of magnitude. Understanding how depth shapes these priors and prediction may help explain the success of neural networks and transformers. We study this connection in large-alphabet prediction through the layered simplex architecture (LSA), which multiplies independent uniform simplex vectors coordinate-wise and normalizes. At depth zero, the prior is concentrated on the uniform distribution; at depth one, the Bayesian predictor is Laplace's rule. Each additional layer shifts prior mass toward more concentrated distributions. We derive exact Bayesian marginal likelihood and regret expressions using reusable depth-specific kernels. Mixing over depths up to a cutoff logarithmic in alphabet size yields an explicit predictor with rigorous guarantees. For targets uniform on a specified sparse support, the mixture's prior complexity is asymptotic to the support-description cost at every fixed positive KL resolution, establishing a broad complexity spectrum. We also prove a regret lower bound for every label-invariant predictor: the expected description length of the discovered symbol set minus the source's uncertainty about its identity given its size. For Zipf sources in a growing-alphabet regime, the depth mixture attains this bound to leading order. Thus, the symbol-discovery rate determines the regret exponent. Although introduced to study depth, the LSA predictor competes with established large-alphabet methods, including Good--Turing, Ristad's law and an adaptive Dirichlet mixture, while substantially outperforming classical add-constant rules on concentrated sources.