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

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

    Sep 17, 2026Vanessa KosoySequence ModelingSequence Prediction

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

    Mar 27, 2026Vanessa KosoySequence PredictionSequence Modeling

  3. A Layered Simplex Architecture for Large Alphabets

    Aug 20, 2026Meir Feder, Yaniv Fogel, Ruediger UrbankeZipf's LawBayesian Inference