SlideShare a Scribd company logo
Ch. 4 Arithmetic Coding




                          1
Motivation – What are Problems w/ Huffman
1.       Can be inefficient (i.e., large redundancy)
     •    This can be “solved” through Block Huffman
     •    But… # of codewords grows exponentially
     See Example 4.2.1: H1(S) = 0.335 bits/symbol
     But using Huffman we get avg length = 1.05 bits/symbol
     Would need block size of 8    6561-symbol alphabet to get close to H1
2.       High-Order Models (Non-IID) Hard to Address
     •      Can be solved through Block Huffman
     •      But # of codewords increases exponentially

         Underlying difficulty: Huffman requires keeping track of
         codewords for all possible blocks

         We need a way to assign a codeword to a particular sequence
         w/o having to generate codes for all possible sequences
                                                                             2
Main Idea of Arithmetic Coding
                                                  1
Sequence: S1 S2 S3 S4 ….         Mapped to…       0.6457351….

 Each possible sequence gets mapped               0

 to a unique number in [0,1)
 • The mapping depends on the prob. of the symbols
 • You don’t need to a priori determine all possible mappings
    – The Mapping is “built” as each new symbol arrives


 Recall CDF of an RV: symbols {a1,a2, a3}  RV X w/ values: {1, 2, 3}
         Consider P(X=1) = 0.7 P(X=2) = 0.1 P(X=1) = 0.2
                         FX(x)
                     1
                   0.8
                   0.7



                         0        1           2   3       x            3
Example: “Vowellish” (from Numerical Recipes Book)




To send “iou”: Send any # C such that
     0.37630 ≤ C < 0.37819
Using Binary Fraction of
   0.011000001 (9 bits)

      9 bits for Arithmetic
                vs
      10 bits for Huffman
                                      ⎧ upper limit ⎫
 As each symbol is processed find new ⎨             ⎬ for interval
                                      ⎩lower limit ⎭                 4
Math Result Needed to Program
Consider a sequence of RVs X = (x1, x2, x3, … , xn) corresponding
to the sequence of symbols (S1, S2, S3, … , Sn)
       Ex.         Alphabet = {a1 , a2 , a3 } → RV Values {1, 2, 3}
              ( S1 S2 S3 S4 ) = ( a2 a3 a3 a1 ) → ( x1 x2 x3 x4 ) = (2 3 31)


 Initial Values:         l (0) = 0         u (0) = 1


 Interval Update: l ( n ) = l ( n −1) + ⎡ u ( n −1) − l ( n −1) ⎤ F ( x − 1)
                                        ⎣                       ⎦ X n
                         u ( n ) = l ( n −1) + ⎡u ( n −1) − l ( n −1) ⎤ FX ( xn )
                                               ⎣                      ⎦

                                         From Prev Interval         From Prob Model

                                                                                      5
Checking Some Characteristics of Update
• What is the smallest l(n) can be?
                                                                                       ( n −1)
       l ( n ) = l ( n −1) + ⎡u ( n −1) − l ( n −1) ⎤ FX ( xn − 1)
                             ⎣                      ⎦                  l   (n)
                                                                                  ≥l
                                         >0                       ≥0



• What is the largest u(n) can be?

         u ( n ) = l ( n −1) + ⎡u ( n −1) − l ( n −1) ⎤ FX ( xn )
                               ⎣                      ⎦
                                                                                         ( n −1)
                                                                  ≤1
                                                                       u    (n)
                                                                                  ≤u
               ≤l   ( n −1)
                              + ⎡u
                                ⎣
                                     ( n −1)
                                               −l   ( n −1)
                                                              ⎤
                                                              ⎦


         These imply an important requirement for decoding:
                    New Interval ⊆ Old Interval

                                                                                                   6
Example of Applying the Interval Update
Symbols {a1,a2, a3} RV X w/ values: {1, 2, 3}
      Consider P(X=1) = 0.7 P(X=2) = 0.1 P(X=1) = 0.2
                           FX(x)
                       1
                     0.8
  CDF for this       0.7
  alphabet/RV

                           0         1           2         3       x

 Consider the sequence (a1 a3 a2) → (1 3 2)
  To process the first symbol “1”
                                                                        FX(0)


       l (1) = l (0) + ⎡u (0) − l (0) ⎤ FX (1 − 1) = 0 + [1 − 0] × 0 = 0
                       ⎣              ⎦
       u (1) = l (0) + ⎡u (0) − l (0) ⎤ FX (1)
                       ⎣              ⎦              = 0 + [1 − 0] × 0.7 = 0.7
                                                                         FX(1)   7
To process the 2nd symbol “3”
                                                                       FX(2)


        l (2) = l (1) + ⎡u (1) − l (1) ⎤ FX (3 − 1) = 0 + [0.7 − 0] × 0.8 = 0.56
                        ⎣              ⎦
        u (2) = l (1) + ⎡u (1) − l (1) ⎤ FX (3)
                        ⎣              ⎦          = 0 + [0.7 − 0] × 1 = 0.7
                                                                        FX(3)

To process the 3rd symbol “2”
                                                                       FX(1)
                                    1010101000
l (3)   = l (2) + ⎡u (2) − l (2) ⎤ FX (2 − 1) = 0.56 + [0.7 − 0.56] × 0.7 = 0.658
                  ⎣              ⎦
u (3) = l (2) + ⎡u (2) − l (2) ⎤ FX (2)
                ⎣              ⎦              = 0.56 + [0.7 − 0.56] × 0.8 = 0.672
                                                                        FX(2)

 So… send a number in the interval [0.658,0.672) Pick 0.6640625

         0.664062510 = 0.10101012                   Code = 1 0 1 0 1 0 1
                                                                                    8
Decoding Received Code = 1 0 1 0 1 0 1
   ⎧0.1111111... = 1                         ⎧0.1011111... = 0.75
1→ ⎨                                    10 → ⎨
   ⎩0.1000000... = 0.5                       ⎩0.1000000... = 0.5

       1                                        1
 a3                                       a3
      0.8                                      0.8
 a2            After 1st bit [0.5 1)…     a2
      0.7      Can’t Decode                    0.7
                                                       After 2nd bit [0.5 0.75)…
                                                       Can’t Decode… But first
                                                       symbol can’t be a3



 a1                                       a1



       0                                        0                                  9
Decoding Continued: Received Code = 1 0 1 0 1 0 1
      ⎧0.1011111... = 0.75               ⎧0.1010111... = 0.6875
101 → ⎨                           1010 → ⎨
      ⎩0.1010000... = 0.625              ⎩0.1010000... = 0.625
        1                                  1
  a3                                 a3
       0.8                                0.8
  a2            [0.625 , 0.75)…      a2
       0.7      Can’t Decode              0.7                                    0.7
                                                 [0.625 , 0.6875)…          a3
                                                 Can Decode 1st symbol!!!
                                                                            a2 0.56
                                                         It is a1                0.49

                                                 Now slice up [0, 0.7)…
  a1                                 a1                                     a1
                                                 …can decode 2nd symbol

                                                         It is a3
        0                                  0                                       0
                                                                                        10
Decoding Continued: Received Code = 1 0 1 0 1 0 1
        ⎧0.1010111... = 0.6875                 ⎧0.10101011... = 0.671875
10101 → ⎨                             101010 → ⎨
        ⎩0.1010100... = 0.65625                ⎩0.10101000... = 0.65625

        0.7                                       0.7
               [0.65625 , 0.6875)…                            [0.65625, 0.671875)…
0.672                                     0.672
               Can’t Decode                                   Can’t Decode
0.658                                     0.658



        0.56                                      0.56

                                                 ⎧0.1010101111... = 0.671875
                                       1010101 → ⎨
                                                 ⎩0.1010101000... = 0.6640625

                                                        0.7
                                                                [0.6640625, 0.671875)
                                              0.672
                                                                Can Decode 3rd symbol!!!
                                              0.658

                                                                        It is a2
                                                      0.56
                      In practice there are ways to handle termination issues!             11
Main Results on Uniqueness & Efficiency
1.      A “binary tag” lying between l(n) and u(n) can be found
2.      The tag can be truncated to a finite # of bits
3.      The truncated tag still lies between l(n) and u(n)
4.      The truncated tag is Unique & Decodable
5.      For IID sequence of length m: H ( S ) ≤ l < H ( S ) + 2
                                                   Arith
                                                                     m
                                                                      1
               Compared to Huffman: H ( S ) ≤ lHuff        < H (S ) +
                                                                      m

     Hey! AC is worse than Huffman??!! So why consider AC???!!!
            Remember, this is for coding the entire length of m symbols…
            You’d need 2m codewords in Huffman… which is impractical!
                     But for AC is VERY practical!!!

      For Huffman must be kept small but for AC it can be VERY large!
                                                                           12
How AC Overcomes Huffman’s Problems
1.       Efficiency: Huffman can only achieve close to H(S) by using
         large block codes… which means you need a pre-designed
         codebook of exponentially growing size
     –      AC enables coding large blocks w/o having to know codewords a priori
     –      w/ AC you just generate the code for the entire given sequence
           •   No a priori codebook is needed
2.       Higher-Order Models: Huffman can use Cond. Prob.
         Models… but you need to build an a priori codebook for each
         context… which means a large codebook
     –      Context coding via conditional probabilities is easy in AC
     –      For each context you have a prob model for the symbols
           •   Next “slicing of the interval” is done using prob model for the currently
               observed context… no need to generate all the a priori codewords!




                                                                                           13
Ex.: 1st Order Cond. Prob Models for AC
 Suppose you have three symbols and you have a 1st order
 conditional probability model for the source emitting these
 symbols…
For the first symbol in the sequence you have a std Prob Model
For subsequent symbols in the sequence you have 3 context models
P ( a1 ) = 0.2   P ( a1 | a1 ) = 0.1      P ( a1 | a2 ) = 0.95     P ( a1 | a3 ) = 0.45
P ( a2 ) = 0.4   P ( a2 | a1 ) = 0.5      P ( a2 | a2 ) = 0.01     P ( a2 | a3 ) = 0.45
P ( a3 ) = 0.4   P ( a3 | a1 ) = 0.4      P ( a3 | a2 ) = 0.04     P ( a3 | a3 ) = 0.1

∑ P(a ) = 1 ∑ P(a
 i
         i
                  i
                         i   | a1 ) = 1   ∑ P(a
                                           i
                                                  i   | a2 ) = 1   ∑ P(a
                                                                    i
                                                                           i   | a3 ) = 1


     Now let’s see how these are used to code the sequence a2 a1 a3
                 Note: Decoder needs to know these models
                                                                                            14
P ( a1 ) = 0.2        P ( a1 | a2 ) = 0.95   P ( a1 | a1 ) = 0.1
P ( a2 ) = 0.4        P ( a2 | a2 ) = 0.01   P ( a2 | a1 ) = 0.5
P ( a3 ) = 0.4        P ( a3 | a2 ) = 0.04   P ( a3 | a1 ) = 0.4
     1




   0.6

                                                         a3
                 a2                a1

   0.2



     0                                                             15
Ex.: Similar for Adaptive Prob. Models
• Start with some a priori “prototype” prob model (could be cond.)
• Do coding with that for awhile as you observe the actual
  frequencies of occurrence of the symbols
   – Use these observations to update the probability models to better model the
     ACTUAL source you have!!
• Can continue to adapt these models as more symbols are
  observed
   – Enables tracking probabilities of source with changing probabilities
• Note: Because the decoder starts with the same prototype model
  and sees the same symbols the coder uses to adapt… it can
  automatically synchronize adaptation of its models to the coder!
   – As long as there are no transmission errors!!!




                                                                                   16
Ad

More Related Content

What's hot (20)

Spread spectrum
Spread spectrumSpread spectrum
Spread spectrum
RUpaliLohar
 
I/O devices - Computer graphics
I/O devices -  Computer graphicsI/O devices -  Computer graphics
I/O devices - Computer graphics
Amritha Davis
 
Adaline and Madaline.ppt
Adaline and Madaline.pptAdaline and Madaline.ppt
Adaline and Madaline.ppt
neelamsanjeevkumar
 
Digital image processing- Compression- Different Coding techniques
Digital image processing- Compression- Different Coding techniques Digital image processing- Compression- Different Coding techniques
Digital image processing- Compression- Different Coding techniques
sudarmani rajagopal
 
Module 4 Arithmetic Coding
Module 4 Arithmetic CodingModule 4 Arithmetic Coding
Module 4 Arithmetic Coding
anithabalaprabhu
 
Cryptography and applications
Cryptography and applicationsCryptography and applications
Cryptography and applications
thai
 
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Stop-and-Wait ARQ Protocol
Stop-and-Wait ARQ ProtocolStop-and-Wait ARQ Protocol
Stop-and-Wait ARQ Protocol
praneetayargattikar
 
Data Compression in Multimedia
Data Compression in MultimediaData Compression in Multimedia
Data Compression in Multimedia
lalithambiga kamaraj
 
digital image processing
digital image processingdigital image processing
digital image processing
Abinaya B
 
Clipping
ClippingClipping
Clipping
Udayan Gupta
 
Unit 2
Unit 2Unit 2
Unit 2
Assistant Professor
 
Filtering in frequency domain
Filtering in frequency domainFiltering in frequency domain
Filtering in frequency domain
GowriLatha1
 
Convolutional codes
Convolutional codesConvolutional codes
Convolutional codes
Abdullaziz Tagawy
 
Kalman filtering and it's applications
Kalman filtering and it's applicationsKalman filtering and it's applications
Kalman filtering and it's applications
MADHAVASAIYENDUVA
 
Lossless predictive coding
Lossless predictive codingLossless predictive coding
Lossless predictive coding
Fahad Israr
 
error control coding
error control coding error control coding
error control coding
Suhad Malayshi
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
Dr. Chandrakant Divate
 
Arithmetic coding
Arithmetic codingArithmetic coding
Arithmetic coding
Vikas Goyal
 
Reed solomon codes
Reed solomon codesReed solomon codes
Reed solomon codes
Samreen Reyaz Ansari
 
I/O devices - Computer graphics
I/O devices -  Computer graphicsI/O devices -  Computer graphics
I/O devices - Computer graphics
Amritha Davis
 
Digital image processing- Compression- Different Coding techniques
Digital image processing- Compression- Different Coding techniques Digital image processing- Compression- Different Coding techniques
Digital image processing- Compression- Different Coding techniques
sudarmani rajagopal
 
Module 4 Arithmetic Coding
Module 4 Arithmetic CodingModule 4 Arithmetic Coding
Module 4 Arithmetic Coding
anithabalaprabhu
 
Cryptography and applications
Cryptography and applicationsCryptography and applications
Cryptography and applications
thai
 
digital image processing
digital image processingdigital image processing
digital image processing
Abinaya B
 
Filtering in frequency domain
Filtering in frequency domainFiltering in frequency domain
Filtering in frequency domain
GowriLatha1
 
Kalman filtering and it's applications
Kalman filtering and it's applicationsKalman filtering and it's applications
Kalman filtering and it's applications
MADHAVASAIYENDUVA
 
Lossless predictive coding
Lossless predictive codingLossless predictive coding
Lossless predictive coding
Fahad Israr
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
Dr. Chandrakant Divate
 
Arithmetic coding
Arithmetic codingArithmetic coding
Arithmetic coding
Vikas Goyal
 

Viewers also liked (20)

06 Arithmetic 1
06 Arithmetic 106 Arithmetic 1
06 Arithmetic 1
anithabalaprabhu
 
Huffman and Arithmetic coding - Performance analysis
Huffman and Arithmetic coding - Performance analysisHuffman and Arithmetic coding - Performance analysis
Huffman and Arithmetic coding - Performance analysis
Ramakant Soni
 
Data compression huffman coding algoritham
Data compression huffman coding algorithamData compression huffman coding algoritham
Data compression huffman coding algoritham
Rahul Khanwani
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
anithabalaprabhu
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
Ehtisham Ali
 
image compression ppt
image compression pptimage compression ppt
image compression ppt
Shivangi Saxena
 
Walkie talkie ppt
Walkie talkie pptWalkie talkie ppt
Walkie talkie ppt
tbs123
 
Huffman coding
Huffman codingHuffman coding
Huffman coding
Bagus Nugroho
 
Grouping
GroupingGrouping
Grouping
AJAL A J
 
Adaptive Huffman Coding
Adaptive Huffman CodingAdaptive Huffman Coding
Adaptive Huffman Coding
anithabalaprabhu
 
Lec7 8 9_10 coding techniques
Lec7 8 9_10 coding techniquesLec7 8 9_10 coding techniques
Lec7 8 9_10 coding techniques
Dom Mike
 
I am an algorithm - workshop on understanding bias in coding
I am an algorithm - workshop on understanding bias in codingI am an algorithm - workshop on understanding bias in coding
I am an algorithm - workshop on understanding bias in coding
Acuity Design
 
Image compression
Image compression Image compression
Image compression
GARIMA SHAKYA
 
Audio compression
Audio compressionAudio compression
Audio compression
priyanka pandey
 
Analog Video
Analog Video Analog Video
Analog Video
Yoss Cohen
 
Mathematical operations in image processing
Mathematical operations in image processingMathematical operations in image processing
Mathematical operations in image processing
Asad Ali
 
Digital Image Processing - Image Compression
Digital Image Processing - Image CompressionDigital Image Processing - Image Compression
Digital Image Processing - Image Compression
Mathankumar S
 
Multimedia system, Architecture & Databases
Multimedia system, Architecture & DatabasesMultimedia system, Architecture & Databases
Multimedia system, Architecture & Databases
Harshita Ved
 
Digital Image Processing - Image Restoration
Digital Image Processing - Image RestorationDigital Image Processing - Image Restoration
Digital Image Processing - Image Restoration
Mathankumar S
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
Huffman and Arithmetic coding - Performance analysis
Huffman and Arithmetic coding - Performance analysisHuffman and Arithmetic coding - Performance analysis
Huffman and Arithmetic coding - Performance analysis
Ramakant Soni
 
Data compression huffman coding algoritham
Data compression huffman coding algorithamData compression huffman coding algoritham
Data compression huffman coding algoritham
Rahul Khanwani
 
Walkie talkie ppt
Walkie talkie pptWalkie talkie ppt
Walkie talkie ppt
tbs123
 
Lec7 8 9_10 coding techniques
Lec7 8 9_10 coding techniquesLec7 8 9_10 coding techniques
Lec7 8 9_10 coding techniques
Dom Mike
 
I am an algorithm - workshop on understanding bias in coding
I am an algorithm - workshop on understanding bias in codingI am an algorithm - workshop on understanding bias in coding
I am an algorithm - workshop on understanding bias in coding
Acuity Design
 
Mathematical operations in image processing
Mathematical operations in image processingMathematical operations in image processing
Mathematical operations in image processing
Asad Ali
 
Digital Image Processing - Image Compression
Digital Image Processing - Image CompressionDigital Image Processing - Image Compression
Digital Image Processing - Image Compression
Mathankumar S
 
Multimedia system, Architecture & Databases
Multimedia system, Architecture & DatabasesMultimedia system, Architecture & Databases
Multimedia system, Architecture & Databases
Harshita Ved
 
Digital Image Processing - Image Restoration
Digital Image Processing - Image RestorationDigital Image Processing - Image Restoration
Digital Image Processing - Image Restoration
Mathankumar S
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
Ad

Similar to Ch 04 Arithmetic Coding (Ppt) (20)

Taylor problem
Taylor problemTaylor problem
Taylor problem
dinhmyhuyenvi
 
03 truncation errors
03 truncation errors03 truncation errors
03 truncation errors
maheej
 
Amth250 octave matlab some solutions (1)
Amth250 octave matlab some solutions (1)Amth250 octave matlab some solutions (1)
Amth250 octave matlab some solutions (1)
asghar123456
 
Ism et chapter_3
Ism et chapter_3Ism et chapter_3
Ism et chapter_3
Drradz Maths
 
Ism et chapter_3
Ism et chapter_3Ism et chapter_3
Ism et chapter_3
Drradz Maths
 
Ism et chapter_3
Ism et chapter_3Ism et chapter_3
Ism et chapter_3
Drradz Maths
 
Assignment6
Assignment6Assignment6
Assignment6
asghar123456
 
02 2d systems matrix
02 2d systems matrix02 2d systems matrix
02 2d systems matrix
Rumah Belajar
 
Unit 1 Operation on signals
Unit 1  Operation on signalsUnit 1  Operation on signals
Unit 1 Operation on signals
Dr.SHANTHI K.G
 
Math report
Math reportMath report
Math report
last4ever
 
數學測試
數學測試數學測試
數學測試
s9007912
 
Interpolation techniques - Background and implementation
Interpolation techniques - Background and implementationInterpolation techniques - Background and implementation
Interpolation techniques - Background and implementation
Quasar Chunawala
 
Tail Probabilities for Randomized Program Runtimes via Martingales for Higher...
Tail Probabilities for Randomized Program Runtimes via Martingales for Higher...Tail Probabilities for Randomized Program Runtimes via Martingales for Higher...
Tail Probabilities for Randomized Program Runtimes via Martingales for Higher...
Satoshi Kura
 
Chapter3 laplace
Chapter3 laplaceChapter3 laplace
Chapter3 laplace
King Mongkut's University of Technology Thonburi
 
1010n3a
1010n3a1010n3a
1010n3a
Faiza Saher
 
Varian, microeconomic analysis, solution book
Varian, microeconomic analysis, solution bookVarian, microeconomic analysis, solution book
Varian, microeconomic analysis, solution book
José Antonio PAYANO YALE
 
Ch33 11
Ch33 11Ch33 11
Ch33 11
schibu20
 
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
The Statistical and Applied Mathematical Sciences Institute
 
Imc2017 day2-solutions
Imc2017 day2-solutionsImc2017 day2-solutions
Imc2017 day2-solutions
Christos Loizos
 
Lesson20 Tangent Planes Slides+Notes
Lesson20   Tangent Planes Slides+NotesLesson20   Tangent Planes Slides+Notes
Lesson20 Tangent Planes Slides+Notes
Matthew Leingang
 
03 truncation errors
03 truncation errors03 truncation errors
03 truncation errors
maheej
 
Amth250 octave matlab some solutions (1)
Amth250 octave matlab some solutions (1)Amth250 octave matlab some solutions (1)
Amth250 octave matlab some solutions (1)
asghar123456
 
02 2d systems matrix
02 2d systems matrix02 2d systems matrix
02 2d systems matrix
Rumah Belajar
 
Unit 1 Operation on signals
Unit 1  Operation on signalsUnit 1  Operation on signals
Unit 1 Operation on signals
Dr.SHANTHI K.G
 
數學測試
數學測試數學測試
數學測試
s9007912
 
Interpolation techniques - Background and implementation
Interpolation techniques - Background and implementationInterpolation techniques - Background and implementation
Interpolation techniques - Background and implementation
Quasar Chunawala
 
Tail Probabilities for Randomized Program Runtimes via Martingales for Higher...
Tail Probabilities for Randomized Program Runtimes via Martingales for Higher...Tail Probabilities for Randomized Program Runtimes via Martingales for Higher...
Tail Probabilities for Randomized Program Runtimes via Martingales for Higher...
Satoshi Kura
 
Varian, microeconomic analysis, solution book
Varian, microeconomic analysis, solution bookVarian, microeconomic analysis, solution book
Varian, microeconomic analysis, solution book
José Antonio PAYANO YALE
 
Lesson20 Tangent Planes Slides+Notes
Lesson20   Tangent Planes Slides+NotesLesson20   Tangent Planes Slides+Notes
Lesson20 Tangent Planes Slides+Notes
Matthew Leingang
 
Ad

More from anithabalaprabhu (20)

Shannon Fano
Shannon FanoShannon Fano
Shannon Fano
anithabalaprabhu
 
Ch 04 Arithmetic Coding ( P P T)
Ch 04  Arithmetic  Coding ( P P T)Ch 04  Arithmetic  Coding ( P P T)
Ch 04 Arithmetic Coding ( P P T)
anithabalaprabhu
 
Compression
CompressionCompression
Compression
anithabalaprabhu
 
Datacompression1
Datacompression1Datacompression1
Datacompression1
anithabalaprabhu
 
Speech Compression
Speech CompressionSpeech Compression
Speech Compression
anithabalaprabhu
 
Z24 4 Speech Compression
Z24   4   Speech CompressionZ24   4   Speech Compression
Z24 4 Speech Compression
anithabalaprabhu
 
Dictor
DictorDictor
Dictor
anithabalaprabhu
 
Dictionary Based Compression
Dictionary Based CompressionDictionary Based Compression
Dictionary Based Compression
anithabalaprabhu
 
Compression Ii
Compression IiCompression Ii
Compression Ii
anithabalaprabhu
 
Lassy
LassyLassy
Lassy
anithabalaprabhu
 
Compression Ii
Compression IiCompression Ii
Compression Ii
anithabalaprabhu
 
Lossy
LossyLossy
Lossy
anithabalaprabhu
 
Planning
PlanningPlanning
Planning
anithabalaprabhu
 
Lossless
LosslessLossless
Lossless
anithabalaprabhu
 
Losseless
LosselessLosseless
Losseless
anithabalaprabhu
 
Lec32
Lec32Lec32
Lec32
anithabalaprabhu
 
Lec5 Compression
Lec5 CompressionLec5 Compression
Lec5 Compression
anithabalaprabhu
 
Huffman Student
Huffman StudentHuffman Student
Huffman Student
anithabalaprabhu
 
Huffman Encoding Pr
Huffman Encoding PrHuffman Encoding Pr
Huffman Encoding Pr
anithabalaprabhu
 
Huffman1
Huffman1Huffman1
Huffman1
anithabalaprabhu
 

Recently uploaded (20)

UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
UiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer OpportunitiesUiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer Opportunities
DianaGray10
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...
BookNet Canada
 
MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents SystemsTrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
Trs Labs
 
Make GenAI investments go further with the Dell AI Factory
Make GenAI investments go further with the Dell AI FactoryMake GenAI investments go further with the Dell AI Factory
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
UiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer OpportunitiesUiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer Opportunities
DianaGray10
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...
BookNet Canada
 
MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents SystemsTrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
Trs Labs
 
Make GenAI investments go further with the Dell AI Factory
Make GenAI investments go further with the Dell AI FactoryMake GenAI investments go further with the Dell AI Factory
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 

Ch 04 Arithmetic Coding (Ppt)

  • 1. Ch. 4 Arithmetic Coding 1
  • 2. Motivation – What are Problems w/ Huffman 1. Can be inefficient (i.e., large redundancy) • This can be “solved” through Block Huffman • But… # of codewords grows exponentially See Example 4.2.1: H1(S) = 0.335 bits/symbol But using Huffman we get avg length = 1.05 bits/symbol Would need block size of 8 6561-symbol alphabet to get close to H1 2. High-Order Models (Non-IID) Hard to Address • Can be solved through Block Huffman • But # of codewords increases exponentially Underlying difficulty: Huffman requires keeping track of codewords for all possible blocks We need a way to assign a codeword to a particular sequence w/o having to generate codes for all possible sequences 2
  • 3. Main Idea of Arithmetic Coding 1 Sequence: S1 S2 S3 S4 …. Mapped to… 0.6457351…. Each possible sequence gets mapped 0 to a unique number in [0,1) • The mapping depends on the prob. of the symbols • You don’t need to a priori determine all possible mappings – The Mapping is “built” as each new symbol arrives Recall CDF of an RV: symbols {a1,a2, a3} RV X w/ values: {1, 2, 3} Consider P(X=1) = 0.7 P(X=2) = 0.1 P(X=1) = 0.2 FX(x) 1 0.8 0.7 0 1 2 3 x 3
  • 4. Example: “Vowellish” (from Numerical Recipes Book) To send “iou”: Send any # C such that 0.37630 ≤ C < 0.37819 Using Binary Fraction of 0.011000001 (9 bits) 9 bits for Arithmetic vs 10 bits for Huffman ⎧ upper limit ⎫ As each symbol is processed find new ⎨ ⎬ for interval ⎩lower limit ⎭ 4
  • 5. Math Result Needed to Program Consider a sequence of RVs X = (x1, x2, x3, … , xn) corresponding to the sequence of symbols (S1, S2, S3, … , Sn) Ex. Alphabet = {a1 , a2 , a3 } → RV Values {1, 2, 3} ( S1 S2 S3 S4 ) = ( a2 a3 a3 a1 ) → ( x1 x2 x3 x4 ) = (2 3 31) Initial Values: l (0) = 0 u (0) = 1 Interval Update: l ( n ) = l ( n −1) + ⎡ u ( n −1) − l ( n −1) ⎤ F ( x − 1) ⎣ ⎦ X n u ( n ) = l ( n −1) + ⎡u ( n −1) − l ( n −1) ⎤ FX ( xn ) ⎣ ⎦ From Prev Interval From Prob Model 5
  • 6. Checking Some Characteristics of Update • What is the smallest l(n) can be? ( n −1) l ( n ) = l ( n −1) + ⎡u ( n −1) − l ( n −1) ⎤ FX ( xn − 1) ⎣ ⎦ l (n) ≥l >0 ≥0 • What is the largest u(n) can be? u ( n ) = l ( n −1) + ⎡u ( n −1) − l ( n −1) ⎤ FX ( xn ) ⎣ ⎦ ( n −1) ≤1 u (n) ≤u ≤l ( n −1) + ⎡u ⎣ ( n −1) −l ( n −1) ⎤ ⎦ These imply an important requirement for decoding: New Interval ⊆ Old Interval 6
  • 7. Example of Applying the Interval Update Symbols {a1,a2, a3} RV X w/ values: {1, 2, 3} Consider P(X=1) = 0.7 P(X=2) = 0.1 P(X=1) = 0.2 FX(x) 1 0.8 CDF for this 0.7 alphabet/RV 0 1 2 3 x Consider the sequence (a1 a3 a2) → (1 3 2) To process the first symbol “1” FX(0) l (1) = l (0) + ⎡u (0) − l (0) ⎤ FX (1 − 1) = 0 + [1 − 0] × 0 = 0 ⎣ ⎦ u (1) = l (0) + ⎡u (0) − l (0) ⎤ FX (1) ⎣ ⎦ = 0 + [1 − 0] × 0.7 = 0.7 FX(1) 7
  • 8. To process the 2nd symbol “3” FX(2) l (2) = l (1) + ⎡u (1) − l (1) ⎤ FX (3 − 1) = 0 + [0.7 − 0] × 0.8 = 0.56 ⎣ ⎦ u (2) = l (1) + ⎡u (1) − l (1) ⎤ FX (3) ⎣ ⎦ = 0 + [0.7 − 0] × 1 = 0.7 FX(3) To process the 3rd symbol “2” FX(1) 1010101000 l (3) = l (2) + ⎡u (2) − l (2) ⎤ FX (2 − 1) = 0.56 + [0.7 − 0.56] × 0.7 = 0.658 ⎣ ⎦ u (3) = l (2) + ⎡u (2) − l (2) ⎤ FX (2) ⎣ ⎦ = 0.56 + [0.7 − 0.56] × 0.8 = 0.672 FX(2) So… send a number in the interval [0.658,0.672) Pick 0.6640625 0.664062510 = 0.10101012 Code = 1 0 1 0 1 0 1 8
  • 9. Decoding Received Code = 1 0 1 0 1 0 1 ⎧0.1111111... = 1 ⎧0.1011111... = 0.75 1→ ⎨ 10 → ⎨ ⎩0.1000000... = 0.5 ⎩0.1000000... = 0.5 1 1 a3 a3 0.8 0.8 a2 After 1st bit [0.5 1)… a2 0.7 Can’t Decode 0.7 After 2nd bit [0.5 0.75)… Can’t Decode… But first symbol can’t be a3 a1 a1 0 0 9
  • 10. Decoding Continued: Received Code = 1 0 1 0 1 0 1 ⎧0.1011111... = 0.75 ⎧0.1010111... = 0.6875 101 → ⎨ 1010 → ⎨ ⎩0.1010000... = 0.625 ⎩0.1010000... = 0.625 1 1 a3 a3 0.8 0.8 a2 [0.625 , 0.75)… a2 0.7 Can’t Decode 0.7 0.7 [0.625 , 0.6875)… a3 Can Decode 1st symbol!!! a2 0.56 It is a1 0.49 Now slice up [0, 0.7)… a1 a1 a1 …can decode 2nd symbol It is a3 0 0 0 10
  • 11. Decoding Continued: Received Code = 1 0 1 0 1 0 1 ⎧0.1010111... = 0.6875 ⎧0.10101011... = 0.671875 10101 → ⎨ 101010 → ⎨ ⎩0.1010100... = 0.65625 ⎩0.10101000... = 0.65625 0.7 0.7 [0.65625 , 0.6875)… [0.65625, 0.671875)… 0.672 0.672 Can’t Decode Can’t Decode 0.658 0.658 0.56 0.56 ⎧0.1010101111... = 0.671875 1010101 → ⎨ ⎩0.1010101000... = 0.6640625 0.7 [0.6640625, 0.671875) 0.672 Can Decode 3rd symbol!!! 0.658 It is a2 0.56 In practice there are ways to handle termination issues! 11
  • 12. Main Results on Uniqueness & Efficiency 1. A “binary tag” lying between l(n) and u(n) can be found 2. The tag can be truncated to a finite # of bits 3. The truncated tag still lies between l(n) and u(n) 4. The truncated tag is Unique & Decodable 5. For IID sequence of length m: H ( S ) ≤ l < H ( S ) + 2 Arith m 1 Compared to Huffman: H ( S ) ≤ lHuff < H (S ) + m Hey! AC is worse than Huffman??!! So why consider AC???!!! Remember, this is for coding the entire length of m symbols… You’d need 2m codewords in Huffman… which is impractical! But for AC is VERY practical!!! For Huffman must be kept small but for AC it can be VERY large! 12
  • 13. How AC Overcomes Huffman’s Problems 1. Efficiency: Huffman can only achieve close to H(S) by using large block codes… which means you need a pre-designed codebook of exponentially growing size – AC enables coding large blocks w/o having to know codewords a priori – w/ AC you just generate the code for the entire given sequence • No a priori codebook is needed 2. Higher-Order Models: Huffman can use Cond. Prob. Models… but you need to build an a priori codebook for each context… which means a large codebook – Context coding via conditional probabilities is easy in AC – For each context you have a prob model for the symbols • Next “slicing of the interval” is done using prob model for the currently observed context… no need to generate all the a priori codewords! 13
  • 14. Ex.: 1st Order Cond. Prob Models for AC Suppose you have three symbols and you have a 1st order conditional probability model for the source emitting these symbols… For the first symbol in the sequence you have a std Prob Model For subsequent symbols in the sequence you have 3 context models P ( a1 ) = 0.2 P ( a1 | a1 ) = 0.1 P ( a1 | a2 ) = 0.95 P ( a1 | a3 ) = 0.45 P ( a2 ) = 0.4 P ( a2 | a1 ) = 0.5 P ( a2 | a2 ) = 0.01 P ( a2 | a3 ) = 0.45 P ( a3 ) = 0.4 P ( a3 | a1 ) = 0.4 P ( a3 | a2 ) = 0.04 P ( a3 | a3 ) = 0.1 ∑ P(a ) = 1 ∑ P(a i i i i | a1 ) = 1 ∑ P(a i i | a2 ) = 1 ∑ P(a i i | a3 ) = 1 Now let’s see how these are used to code the sequence a2 a1 a3 Note: Decoder needs to know these models 14
  • 15. P ( a1 ) = 0.2 P ( a1 | a2 ) = 0.95 P ( a1 | a1 ) = 0.1 P ( a2 ) = 0.4 P ( a2 | a2 ) = 0.01 P ( a2 | a1 ) = 0.5 P ( a3 ) = 0.4 P ( a3 | a2 ) = 0.04 P ( a3 | a1 ) = 0.4 1 0.6 a3 a2 a1 0.2 0 15
  • 16. Ex.: Similar for Adaptive Prob. Models • Start with some a priori “prototype” prob model (could be cond.) • Do coding with that for awhile as you observe the actual frequencies of occurrence of the symbols – Use these observations to update the probability models to better model the ACTUAL source you have!! • Can continue to adapt these models as more symbols are observed – Enables tracking probabilities of source with changing probabilities • Note: Because the decoder starts with the same prototype model and sees the same symbols the coder uses to adapt… it can automatically synchronize adaptation of its models to the coder! – As long as there are no transmission errors!!! 16