English

Efficiency of ANS Entropy Encoders

Information Theory 2026-02-04 v3 Data Structures and Algorithms math.IT

Abstract

Asymmetric Numeral Systems (ANS) is a class of entropy encoders that had an immense impact on the data compression, substituting arithmetic and Huffman coding. It was studied by different authors but the precise asymptotics of its redundancy (in relation to the entropy) was not completely understood. We obtain optimal bounds for the redundancy of the tabled ANS (tANS), the most popular ANS variant. Given a sequence a1,a2,,ana_1,a_2,\ldots,a_n of symbols from an alphabet {0,1,,σ1}\{0,1,\ldots,\sigma-1\} such that each symbol aa occurs in it faf_a times and n=2rn=2^r, the tANS encoder using Duda's ``precise initialization'' to fill tANS tables transforms this sequence into a bit string of the following length (the frequencies are not included in the encoding): a[0..σ)falognfa+O(σ+r)\sum\limits_{a\in[0..\sigma)}f_a\cdot\log\frac{n}{f_a}+O(\sigma+r), where O(σ+r)O(\sigma+r) can be bounded by σloge+r\sigma\log e+r. The rr-bit term is an artifact indispensable to ANS; the rest incurs a redundancy of O(σn)O(\frac{\sigma}{n}) bits per symbol. We complement this by examples showing that an Ω(σ+r)\Omega(\sigma+r) redundancy is necessary. We argue that similar examples exist for most adequate initialization methods for tANS. Thus, we refute Duda's conjecture that the redundancy is O(σn2)O(\frac{\sigma}{n^2}) bits per symbol. We also propose a variant of the range ANS (rANS), called rANS with fixed accuracy, parameterized by k1k\ge 1 that in certain conditions might be faster than the standard rANS because it avoids slow explicit division operations. We bound the redundancy for our rANS variant by n2k1loge+r+k\frac{n}{2^k-1}\log e+r+k.

Keywords

Cite

@article{arxiv.2201.02514,
  title  = {Efficiency of ANS Entropy Encoders},
  author = {Dmitry Kosolobov},
  journal= {arXiv preprint arXiv:2201.02514},
  year   = {2026}
}

Comments

25 pages, 5 figures, 1 table, 2 listings

R2 v1 2026-06-24T08:42:56.931Z