Arithmetic Coding
Arithmetic Coding
Arithmetic Coding
Thinh Nguyen
Oregon State University
Representation of Real Number in
Binary
Real-to-Binary Conversion Algorithm
Arithmetic Coding
Basic idea in arithmetic coding (Shannon-Fano-
Elias):
14/27
Examples
Code Generation from Tags
Guaranteed Code Example
Arithmetic Coding Algorithm
C(xi) = P(x0) + P(x1) + … P(xi)
Initialize L: = 0 and R: = 1;
For i = 1 to n do
W:= R – L;
L: = L + W*C(xi-1);
R := L + W*C(xi);
T: = (L+R)/2;
Choose code for the tag
Example
P(A) = ¼, P(b) = ½ , P(c) = ¼
C(a) = ¼, C(b) = ¾, C(c) = 1
abca
Example
P(A) = ¼, P(b) = ½ , P(c) = ¼
C(a) = ¼, C(b) = ¾, C(c) = 1
bbbb
Decoding
Decoding
Decoding
Arithmetic Decoding Algorithm
C(xi) = P(x0) + P(x1) + … P(xi)
Decode b1b2 …bm, the number of symbols in n
Efficiency:
Proof: