ArticleslgStudy

astronomy

Universal code (data compression)

Universal code (data compression) is a astronomy topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Universal code (data compression) rather than just read about it. In short: In data compression, a universal code for integers is a prefix code that maps the positive integers onto binary codewords, with the additional property that whatever the true probability distribution on integers, as long as the distribution is monotonic (i.e., p(i) ≥ p(i + 1) for all positive i), the expected lengths of the codewords are within a constant factor of the expected lengths that the optimal code for that…

Universal code (data compression) — main illustration
Universal code (data compression) — illustration

Key takeaways

  • Universal code (data compression) belongs to astronomy; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Universal code (data compression) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Universal code (data compression) from memory before moving on to harder problems.

Reference excerpt

In data compression, a universal code for integers is a prefix code that maps the positive integers onto binary codewords, with the additional property that whatever the true probability distribution on integers, as long as the distribution is monotonic (i.e., p(i) ≥ p(i + 1) for all positive i), the expected lengths of the codewords are within a constant factor of the expected lengths that the optimal code for that probability distribution would have assigned. A universal code is asymptotically optimal if the ratio between actual and optimal expected lengths is bounded by a function of the information entropy of the code that, in addition to being bounded, approaches 1 as entropy approaches infinity. In general, most prefix codes for integers assign longer codewords to larger integers. Such a code can be used to efficiently communicate a message drawn from a set of possible messages, by simply ordering the set of messages by decreasing probability and then sending the index of the intended message. Universal codes are generally not used for precisely known probability distributions, and no universal code is known to be optimal for any distribution used in practice. A universal code should not be confused with universal source coding, in which the data compression method need not be a fixed prefix code and the ratio between actual and optimal expected lengths must approach one. However, note that an asymptotically optimal universal code can be used on independent identically-distributed sources, by using increasingly large blocks, as a method of universal source coding.

Universal and non-universal codes These are some universal codes for integers; an asterisk (*) indicates a code that can be trivially restated in lexicographical order, while a double dagger (‡) indicates a code that is asymptotically optimal:

Elias gamma coding * Elias delta coding * ‡ Elias omega coding * ‡ Exp-Golomb coding *, which has Elias gamma coding as a special case. (Used in H.264/MPEG-4 AVC) Fibonacci coding Levenshtein coding * ‡, the original universal coding technique [1] Byte coding where a special bit pattern (with at least two bits) is used to mark the end of the code — for example, if an integer is encoded as a sequence of nibbles representing digits in base 15 instead of the more natural base 16, then the highest nibble value (i.e., a sequence of four ones in binary) can be used to indicate the end of the integer. Variable-length quantity These are non-universal ones:

Unary coding, which is used in Elias codes Rice coding, which is used in the FLAC audio codec and which has unary coding as a special case Golomb coding, which has Rice coding and unary coding as special cases. Their nonuniversality can be observed by noticing that, if any of these are used to code the Gauss–Kuzmin distribution or the Zeta distribution with parameter s=2, expected codeword length is infinite. For example, using unary coding on the Zeta distribution yields an expected length of

E ( l ) = 6 π 2 ∑ l = 1 ∞ 1 l = ∞ . {\displaystyle E(l)={\frac {6}{\pi ^{2}}}\sum _{l=1}^{\infty }{\frac {1}{l}}=\infty .\,}

On the other hand, using the universal Elias gamma coding for the Gauss–Kuzmin distribution results in an expected codeword length (about 3.51 bits) near entropy (about 3.43 bits).

Relationship to practical compression Huffman coding and arithmetic coding (when they can be used) give at least as good, and often better compression than any universal code. However, universal codes are useful when Huffman coding cannot be used — for example, when one does not know the exact probability of each message, but only knows the rankings of their probabilities. Universal codes are also useful when Huffman codes are inconvenient. For example, when the transmitter but not the receiver knows the probabilities of the messages, Huffman coding requires an overhead of transmitting those probabilities to the receiver. Using a universal code does not have that overhead. Each universal code, like each other self-delimiting (prefix) binary code, has its own "implied probability distribution" given by P(i)=2−l(i) where l(i) is the length of the ith codeword and P(i) is the corresponding symbol's probability. If the actual message probabilities are Q(i) and Kullback–Leibler divergence D KL ( Q ‖ P ) {\displaystyle D_{\text{KL}}(Q\|P)} is minimized by the code with l(i), then the optimal Huffman code for that set of messages will be equivalent to that code. Likewise, how close a code is to optimal can be measured by this divergence. Since universal codes are simpler and faster to encode and decode than Huffman codes (which is, in turn, simpler and faster than arithmetic encoding), the universal code would be preferable in cases where D KL ( Q ‖ P ) {\displaystyle D_{\text{KL}}(Q\|P)} is sufficiently small. Lossless Data Compression Program: Hybrid LZ77 RLE For any geometric distribution (an exponential distribution on integers), a Golomb code is optimal. With universal codes, the implicit distribution is approximately a power law such as 1 / n 2 {\displaystyle 1/n^{2}} (more precisely, a Zipf distribution). For the Fibonacci code, the implicit distribution is approximately 1 / n q {\displaystyle 1/n^{q}} , with

… excerpt ends here. Continue reading the full article.

Illustrations

Universal code (data compression): Fibonacci, Elias Gamma, and Elias Delta vs binary coding
Fibonacci, Elias Gamma, and Elias Delta vs binary coding
Universal code (data compression): Rice with k = 2, 3, 4, 5, 8, 16 versus binary
Rice with k = 2, 3, 4, 5, 8, 16 versus binary

Worked examples

Example 1 — a first encounter with Universal code (data compression)

Start with the simplest possible case. Write down what Universal code (data compression) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In astronomy, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Universal code (data compression) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Universal code (data compression) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Universal code (data compression)

In research
Universal code (data compression) appears in astronomy research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Universal code (data compression) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Universal code (data compression) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Data compression, Entropy coding, so understanding it makes those chapters shorter.
In everyday life
Look for Universal code (data compression) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Universal code (data compression)” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Universal code (data compression) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Universal code (data compression) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Universal code (data compression) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Universal code (data compression) in simple terms?

In data compression, a universal code for integers is a prefix code that maps the positive integers onto binary codewords, with the additional property that whatever the true probability distribution on integers, as long as the distribution is monotonic (i.e., p(i) ≥ p(i + 1) for all positive i), t…

Why does Universal code (data compression) matter?

Because it connects several astronomy ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Universal code (data compression)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Universal code (data compression).

Tags

  • Data compression
  • Entropy coding

Keep exploring