Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
139 views

Arithmetic Coding

Arithmetic coding is a method of encoding symbols into code words that represents groups or sequences of symbols with a unique fractional tag between 0 and 1. The tag is mapped to the sequence using the cumulative distribution function of the random variables associated with the data source. During decoding, the tag value and probability model are used to iteratively decode each symbol in the sequence by identifying the interval containing the tag value. The tag can then be represented with a binary code that is an efficient representation of the encoded sequence.

Uploaded by

ramadevi
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views

Arithmetic Coding

Arithmetic coding is a method of encoding symbols into code words that represents groups or sequences of symbols with a unique fractional tag between 0 and 1. The tag is mapped to the sequence using the cumulative distribution function of the random variables associated with the data source. During decoding, the tag value and probability model are used to iteratively decode each symbol in the sequence by identifying the interval containing the tag value. The tag can then be represented with a binary code that is an efficient representation of the encoded sequence.

Uploaded by

ramadevi
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

Arithmetic Coding

Arithmetic Coding
 Generating code words for groups or sequences of
symbols
 A unique identifier or tag is generated for the
sequence to be encoded
 This tag is a fraction and it is binary encoded
 The set of tags for representing symbols are the
numbers in the unit interval [0,1)
 Number of numbers in the unit interval is infinite.
 Unique tag can be generated for each sequence.
Arithmetic Coding
 Cumulative distribution function of the random
variables associated with the source is used for
mapping the sequence to a tag.
Generating the tag:
 Example:
 Consider a three-letter alphabet A = {a1, a2, a3} with
 P(a1) = 0.7,P(a2) = 0.1, and P(a3) = 0.2.
 Fx(1) = 0.7, Fx (2) = 0.8, and Fx(3) = 1.
 This partitions the unit interval as shown in Figure.
Arithmetic Coding
0.0 0.0 0.49 0.546

a1 a1 a1 a1

0.7 0.49 0.539 0.5558


a2 a2
a2 a2
0.8 0.56 0.546 0.5572
a3 a3 a3 a3
1.0 0.70 0.56
0.56
Arithmetic Coding
 The interval in which the tag for a particular sequence
resides is disjoint from all intervals in which the tag
for any other sequence may reside.

 Any number in this interval can be used as the tag(say,


mid point/lower value).

 the tag forms a unique representation for the sequence.


This means that the binary representation of the tag
forms a unique binary code for the sequence.
Arithmetic Coding
 We can show that for any sequence
x = (x1, x2,….xn)
l ( n )  l ( n 1)  (u ( n 1)  l ( n 1) ) FX ( xn  1)
u ( n )  l ( n 1)  (u ( n 1)  l ( n 1) ) FX ( xn )
u (n)  l (n)
TX ( x ) 
2
 The only information required by the tag generation
procedure is the cdf of the source, which can be
obtained directly from the probability model.
Example

 Given a DMS A = {a1, a2, a3}


 P(a1) = 0.8, P(a2) =0.02 P(a3) =0.18
 Obtain tag for a1 a3 a2 a1.

 Ans. Tag = 0.772352


Deciphering (Decoding) the tag
 Given Tag Value, Probability model & length of the
block

 Tag value = 0.772352

 The interval containing this tag value is the subset of


every interval obtained in the encoding process.
While decoding, decode the elements in such a way
that upper and lower limits always contain this tag
value.
Decoding
 Start with l(0) =0, u(0) =1
 Let the first element is decoded as x1. Then,
 l(1)= 0 +(1-0)Fx(x1-1)=Fx(x1-1)
 u(1) =0 +(1-0)Fx(x1)=Fx(x1)

 Find the value of x1 for which this interval contains


the tag value.
 If we pick x1=1, the interval is [0,0.8). If we pick
x1=2, the interval is [0.8,0.82), and if we pick x1=3,
the interval is [0.82,1.0). As 0.77232 lies in the
interval [0.0,0.8), we choose x1=1
Decoding
 Let the second element is x2.

 l(2)= 0 +(0.8-0)Fx(x2-1)=0.8 Fx(x2-1)


 u(2) =0 +(0.8-0)Fx(x2)=0.8 Fx(x2)

 If we pick x2=1, the updated interval is [0, 0.64,), which


does not contain the tag.
 If we pick x2=2, the updated interval is [0.64, 0.656),
which also does not contain the tag.
 If we pick x2=3, the updated interval is [0.656, 0.8) which
contains the tag.
 Therefore second element is 3.
Decoding
 Let the third element is x3.

 l (3) = 0.656 +(0.8-0.656) Fx(x3 -1) = 0.656 + 0.144 Fx(x3 -1)


 u (3) = 0.656 +(0.8-0.656) Fx(x3) = 0.656 + 0.144 Fx(x3)

 Subtract the value of l(2) from both the limits and the tag.
 Find the value of x3 for which the interval [0.144 x Fx (x3 -1),
0.144 x Fx (x3)) contains 0.772352 - 0.656 (Residual tag)
 Divide the residual tag value by 0.144 to get 0.808.
 Find the value of x3 for which 0.808 falls in the interval [Fx(x3-
1), Fx(x3) ). It is possible if x3 =2.
 Then update the intervals.
Decoding
 Let the fourth element is x4.

 l (4) = 0.7712 +(0.77408-0.7712) Fx(x4-1) =


0.7712 + 0.00288 Fx(x4-1)
 u (4) = 0.7712 +(0.77408-0.7712) Fx(x4) =
0.7712 + 0.00288 Fx(x4)

 Subtract the value of l(3) from both the limits and the tag. (0.772352 - 0.7712
=0.001152)
 Find the value of x4 for which the interval [0. 00288 x Fx (x4 -1), 0.00288 x
Fx (x4)) contains 0.001152 (Residual tag)
 Divide the residual tag value by 0. 00288 to get 0.4.
 Find the value of x4 for which 0.4 falls in the interval [Fx(x4-1), Fx(x4) ). It is
possible if x4 =1.
 Data is decoded as 1321 i.e., a1 a3 a2 a1
Generating a binary code
 To make the code efficient, the binary representation has
to be truncated. Tag is a number in the interval [0,1).
 A binary code for the tag can be obtained by taking the
binary representation of this number and truncating it to
l(x) bits.
l ( x)   log(1 / p ( x))   1
Generating a binary code
 Example A ={a1, a2, a3,a4}
P(a1) = 1/2, P(a2) =1/4, P(a3) =1/8 , P(a4)=1/8

Symbol Fx Tag In binary  1 


log p ( x)   1 Code
 

1 0.5 .25 .010 2 01

2 0.75 .625 .101 3 101

3 0.875 .8125 .1101 4 1101

4 1.0 .9375 .1111 4 1111


Efficiency of Arithmetic Coding
 Average codeword length (Rate)

1 2
H(X)   l A  H(X) 
m m

You might also like