← Latest papers
💻 computer science

Efficiency of ANS Entropy Encoders

This paper establishes optimal redundancy bounds for tabled Asymmetric Numeral Systems (tANS), disproving a conjecture that the redundancy is O(σ/n2)O(\sigma/n^2) by proving it is actually O(σ/n)O(\sigma/n), while also proposing and analyzing a faster rANS variant with fixed accuracy.

Original authors: Dmitry Kosolobov

Published 2026-02-04
📖 5 min read🧠 Deep dive

Original authors: Dmitry Kosolobov

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Big Picture: Packing a Suitcase Efficiently

Imagine you are trying to pack a suitcase (your data) to send it across the world. You want the suitcase to be as small as possible to save on shipping costs (bandwidth/storage).

In the world of data compression, there are two main ways to pack your items:

  1. Huffman Coding: Like sorting your clothes by type and putting all shirts in one bag, all pants in another. It's fast, but sometimes leaves empty air in the bags.
  2. Arithmetic Coding: Like squeezing every single item into a vacuum-sealed bag. It's incredibly efficient (tiny size), but it takes a long time to pack and unpack.

ANS (Asymmetric Numeral Systems) is a new method invented by Jarek Duda that claims to be the "best of both worlds." It squeezes the data as tightly as Arithmetic Coding but packs it as fast as Huffman Coding. It has become the standard in modern file formats (like images and video).

The Problem: The "Leftover" Space

While everyone knows ANS is fast and good, nobody was 100% sure exactly how much "wasted space" (redundancy) it leaves behind compared to the theoretical perfect limit.

Think of redundancy as the extra air left in the suitcase.

  • The Old Guess: Some experts thought the wasted space was microscopic, almost zero.
  • The Author's Discovery: Kosolobov proves that the wasted space is actually a bit larger than previously thought. It's not microscopic; it's a small but noticeable amount that depends on how many different types of items (symbols) you have.

The Main Findings (The "TANS" Variant)

The paper focuses on the most popular version of ANS, called tANS (tabled ANS).

1. The Upper Bound (The Worst-Case Scenario)
Kosolobov calculated the maximum amount of extra space tANS will ever use.

  • The Formula: The extra space is roughly proportional to the number of different symbol types (σ\sigma) divided by the total number of items (nn).
  • The Analogy: Imagine you have a suitcase with 1,000 items. If you have 10 different types of items, the "wasted air" is small. But if you have 500 different types of items, the wasted air becomes significant.
  • The Verdict: The paper proves the waste is about O(σ/n)O(\sigma/n) bits per symbol. This is a "tight" bound, meaning it's the most accurate estimate possible.

2. The Lower Bound (The "You Can't Do Better" Proof)
The author didn't just guess the maximum; he proved you can't do much better.

  • The Experiment: He created a specific, tricky sequence of data (like a suitcase filled with very specific, alternating items) that forces the ANS encoder to leave behind a specific amount of extra space.
  • The Result: He showed that for certain data patterns, the wasted space is at least σ/4\sigma/4 bits.
  • Why it matters: This disproves a previous guess by the inventor of ANS (Duda) that the waste could be as tiny as O(σ/n2)O(\sigma/n^2). Kosolobov says, "Sorry, that's too optimistic. Here is a proof that the waste is actually bigger."

3. The "R" Factor (The Initial Setup Cost)
There is a fixed cost of rr bits (where n=2rn = 2^r) that is always added to the suitcase, regardless of the data.

  • The Analogy: This is like the weight of the suitcase itself. Even if you pack it with nothing, the suitcase weighs something. The paper acknowledges this is an unavoidable "artifact" of how the system starts, but it's a fixed cost, not a per-item cost.

The Second Contribution: A New "Fixed Accuracy" rANS

The paper also introduces a new variation of ANS called rANS with fixed accuracy.

The Problem with Standard rANS:
Standard rANS is great because it doesn't need a giant lookup table (it saves memory), which is perfect for adaptive systems (where the data changes as you go). However, it has a slow step: Division.

  • The Analogy: Imagine you are packing, and every time you add an item, you have to stop and do a complex math problem (division) to figure out where it goes. This slows you down.

The New Solution:
Kosolobov created a version where the "math problem" is simplified.

  • How it works: He sets a rule (parameter kk) that guarantees the result of the division always falls into a specific, small range.
  • The Benefit: Because the result is predictable, the computer doesn't need to do the slow, heavy division. It can use faster, simpler tricks (like bit-shifting) to get the answer.
  • The Trade-off:
    • Encoding (Packing): It is faster than the standard rANS with division, but slightly slower than the "super-fast" rANS that uses pre-calculated constants.
    • Decoding (Unpacking): It is slower than the standard version.
  • When to use it: This is useful if you are building a system that needs to adapt to changing data on the fly (where you can't pre-calculate constants) and speed during packing is your top priority.

Summary of the Paper's Claims

  1. We fixed the math: We now know exactly how much "wasted space" the popular tANS encoder leaves behind. It is more than people thought (O(σ/n)O(\sigma/n)), and we proved you can't make it much smaller.
  2. We debunked a myth: The idea that the waste could be tiny (O(σ/n2)O(\sigma/n^2)) is false for standard initialization methods.
  3. We built a new tool: We created a new version of rANS that avoids slow division operations, making it faster for specific adaptive scenarios, though it comes with a slight speed penalty during decoding.

The paper is a "theoretical plumbing" job: it measures the pipes, finds the leaks, and suggests a new valve design, ensuring we understand the limits of this powerful compression technology.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →