ArticleslgStudy

science

Golomb coding

Golomb coding is a science 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 Golomb coding rather than just read about it. In short: Golomb coding is a lossless data compression method using a family of data compression codes invented by Solomon W. Golomb in the 1960s.

Golomb coding — main illustration
Golomb coding — illustration

Key takeaways

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

Reference excerpt

Golomb coding is a lossless data compression method using a family of data compression codes invented by Solomon W. Golomb in the 1960s. Alphabets following a geometric distribution will have a Golomb code as an optimal prefix code, making Golomb coding highly suitable for situations in which the occurrence of small values in the input stream is significantly more likely than large values.

Rice coding Rice coding (invented by Robert F. Rice) denotes using a subset of the family of Golomb codes to produce a simpler (but possibly suboptimal) prefix code. Rice used this set of codes in an adaptive coding scheme; "Rice coding" can refer either to that adaptive scheme or to using that subset of Golomb codes. Whereas a Golomb code has a tunable parameter that can be any positive integer value, Rice codes are those in which the tunable parameter is a power of two. This makes Rice codes convenient for use on a computer, since multiplication and division by 2 can be implemented more efficiently in binary arithmetic. Rice was motivated to propose this simpler subset due to the fact that geometric distributions are often varying with time, not precisely known, or both, so selecting the seemingly optimal code might not be very advantageous. Rice coding is used as the entropy encoding stage in a number of lossless image compression and audio data compression methods.

Overview

Construction of codes Golomb coding uses a tunable parameter M to divide an input value x into two parts: q, the result of a division by M, and r, the remainder. The quotient is sent in unary coding, followed by the remainder in truncated binary encoding. When M = 1 {\displaystyle M=1} , Golomb coding is equivalent to unary coding. Golomb–Rice codes can be thought of as codes that indicate a number by the position of the bin (q), and the offset within the bin (r). The example figure shows the position q and offset r for the encoding of integer x using Golomb–Rice parameter M = 3, with source probabilities following a geometric distribution with p(0) = 0.2. Formally, the two parts are given by the following expression, where x is the nonnegative integer being encoded:

q = ⌊ x M ⌋ {\displaystyle q=\left\lfloor {\frac {x}{M}}\right\rfloor }

and

r = x − q M . {\displaystyle r=x-qM.}

Both q and r will be encoded using variable numbers of bits: q by a unary code, and r by b bits for Rice code, or a choice between b and b+1 bits for Golomb code (i.e. M is not a power of 2), with b = ⌊ log 2 ⁡ ( M ) ⌋ {\displaystyle b=\lfloor \log _{2}(M)\rfloor } . If r < 2 b + 1 − M {\displaystyle r<2^{b+1}-M} , then use b bits to encode r; otherwise, use b+1 bits to encode r. Clearly, b = log 2 ⁡ ( M ) {\displaystyle b=\log _{2}(M)} if M is a power of 2 and we can encode all values of r with b bits. The integer x treated by Golomb was the run length of a Bernoulli process, which has a geometric distribution starting at 0. The best choice of parameter M is a function of the corresponding Bernoulli process, which is parameterized by p = P ( x = 0 ) {\displaystyle p=P(x=0)} the probability of success in a given Bernoulli trial. M is either the median of the distribution or the median ±1. It can be determined by these inequalities:

( 1 − p ) M + ( 1 − p ) M + 1 ≤ 1 < ( 1 − p ) M − 1 + ( 1 − p ) M , {\displaystyle (1-p)^{M}+(1-p)^{M+1}\leq 1<(1-p)^{M-1}+(1-p)^{M},}

which are solved by

M = ⌈ − log ⁡ ( 2 − p ) log ⁡ ( 1 − p ) ⌉ . {\displaystyle M=\left\lceil -{\frac {\log(2-p)}{\log(1-p)}}\right\rceil .}

For the example with p(0) = 0.2:

M = ⌈ − log ⁡ ( 1.8 ) log ⁡ ( 0.8 ) ⌉ = ⌈ 2.634 ⌉ = 3. {\displaystyle M=\left\lceil -{\frac {\log(1.8)}{\log(0.8)}}\right\rceil =\left\lceil 2.634\right\rceil =3.}

The Golomb code for this distribution is equivalent to the Huffman code for the same probabilities, if it were possible to compute the Huffman code for the infinite set of source values.

… excerpt ends here. Continue reading the full article.

Illustrations

Golomb coding: This image shows the redundancy, in bits, of the Golomb code, when M is chosen optimally, for  1 − p(0) ≥ 0.45
This image shows the redundancy, in bits, of the Golomb code, when M is chosen optimally, for 1 − p(0) ≥ 0.45
Golomb coding: Golomb-coded Rice algorithm experiment compression ratios
Golomb-coded Rice algorithm experiment compression ratios

Worked examples

Example 1 — a first encounter with Golomb coding

Start with the simplest possible case. Write down what Golomb coding claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, 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 Golomb coding 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 Golomb coding 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 Golomb coding

In research
Golomb coding appears in science 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 Golomb coding 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
Golomb coding 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 Golomb coding 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 “Golomb coding” →

Affiliate

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

How to study Golomb coding in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Golomb coding 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 Golomb coding out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Golomb coding in simple terms?

Golomb coding is a lossless data compression method using a family of data compression codes invented by Solomon W. Golomb in the 1960s.

Why does Golomb coding matter?

Because it connects several science 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 Golomb coding?

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 Golomb coding.

Tags

  • Data compression
  • Entropy coding

Keep exploring