ArticleslgStudy

computer science

Shannon–Fano–Elias coding

Shannon–Fano–Elias coding is a computer 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 Shannon–Fano–Elias coding rather than just read about it. In short: In information theory, Shannon–Fano–Elias coding is a precursor to arithmetic coding, in which probabilities are used to determine codewords. It is named for Claude Shannon, Robert Fano, and Peter Elias.

Shannon–Fano–Elias coding — main illustration
Shannon–Fano–Elias coding — illustration

Key takeaways

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

Reference excerpt

In information theory, Shannon–Fano–Elias coding is a precursor to arithmetic coding, in which probabilities are used to determine codewords. It is named for Claude Shannon, Robert Fano, and Peter Elias.

Algorithm description Given a discrete random variable X of ordered values to be encoded, let p ( x ) {\displaystyle p(x)} be the probability for any x in X. Define a function

F ¯ ( x ) = ∑ x i < x p ( x i ) + 1 2 p ( x ) {\displaystyle {\bar {F}}(x)=\sum _{x_{i}<x}p(x_{i})+{\frac {1}{2}}p(x)}

Algorithm:

For each x in X, Let Z be the binary expansion of F ¯ ( x ) {\displaystyle {\bar {F}}(x)} . Choose the length of the encoding of x, L ( x ) {\displaystyle L(x)} , to be the integer ⌈ log 2 ⁡ 1 p ( x ) ⌉ + 1 {\displaystyle \left\lceil \log _{2}{\frac {1}{p(x)}}\right\rceil +1}

Choose the encoding of x, c o d e ( x ) {\displaystyle code(x)} , be the first L ( x ) {\displaystyle L(x)} most significant bits after the decimal point of Z.

Example Let X = {A, B, C, D}, with probabilities p = {1/3, 1/4, 1/6, 1/4}.

For A

F ¯ ( A ) = 1 2 p ( A ) = 1 2 ⋅ 1 3 = 0.1666 … {\displaystyle {\bar {F}}(A)={\frac {1}{2}}p(A)={\frac {1}{2}}\cdot {\frac {1}{3}}=0.1666\ldots }

In binary, Z(A) = 0.0010101010...

L ( A ) = ⌈ log 2 ⁡ 1 1 3 ⌉ + 1 = 3 {\displaystyle L(A)=\left\lceil \log _{2}{\frac {1}{\frac {1}{3}}}\right\rceil +1=\mathbf {3} }

code(A) is 001 For B

F ¯ ( B ) = p ( A ) + 1 2 p ( B ) = 1 3 + 1 2 ⋅ 1 4 = 0.4583333 … {\displaystyle {\bar {F}}(B)=p(A)+{\frac {1}{2}}p(B)={\frac {1}{3}}+{\frac {1}{2}}\cdot {\frac {1}{4}}=0.4583333\ldots }

In binary, Z(B) = 0.01110101010101...

L ( B ) = ⌈ log 2 ⁡ 1 1 4 ⌉ + 1 = 3 {\displaystyle L(B)=\left\lceil \log _{2}{\frac {1}{\frac {1}{4}}}\right\rceil +1=\mathbf {3} }

code(B) is 011 For C

F ¯ ( C ) = p ( A ) + p ( B ) + 1 2 p ( C ) = 1 3 + 1 4 + 1 2 ⋅ 1 6 = 0.66666 … {\displaystyle {\bar {F}}(C)=p(A)+p(B)+{\frac {1}{2}}p(C)={\frac {1}{3}}+{\frac {1}{4}}+{\frac {1}{2}}\cdot {\frac {1}{6}}=0.66666\ldots }

In binary, Z(C) = 0.101010101010...

L ( C ) = ⌈ log 2 ⁡ 1 1 6 ⌉ + 1 = 4 {\displaystyle L(C)=\left\lceil \log _{2}{\frac {1}{\frac {1}{6}}}\right\rceil +1=\mathbf {4} }

code(C) is 1010 For D

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Shannon–Fano–Elias coding

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

In research
Shannon–Fano–Elias coding appears in computer 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 Shannon–Fano–Elias 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
Shannon–Fano–Elias coding is common in secondary-school and first-year university syllabi. It links to neighbouring topics Data compression, Lossless compression algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Shannon–Fano–Elias 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 “Shannon–Fano–Elias coding” →

Affiliate

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

How to study Shannon–Fano–Elias coding in 20 minutes

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

Frequently asked questions

What is Shannon–Fano–Elias coding in simple terms?

In information theory, Shannon–Fano–Elias coding is a precursor to arithmetic coding, in which probabilities are used to determine codewords. It is named for Claude Shannon, Robert Fano, and Peter Elias.

Why does Shannon–Fano–Elias coding matter?

Because it connects several computer 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 Shannon–Fano–Elias 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 Shannon–Fano–Elias coding.

Tags

  • Data compression
  • Lossless compression algorithms

Keep exploring