SlideShare uma empresa Scribd logo
1 de 16
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

23 industrial engineering
23 industrial engineering23 industrial engineering
23 industrial engineeringmloeb825
 
Journey to structure from motion
Journey to structure from motionJourney to structure from motion
Journey to structure from motionJa-Keoung Koo
 
Unit3 jwfiles
Unit3 jwfilesUnit3 jwfiles
Unit3 jwfilesmrecedu
 
CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10fungfung Chen
 
Lesson 8: Basic Differentiation Rules (Section 21 slides)
Lesson 8: Basic Differentiation Rules (Section 21 slides)Lesson 8: Basic Differentiation Rules (Section 21 slides)
Lesson 8: Basic Differentiation Rules (Section 21 slides)Matthew Leingang
 
Signal Processing Course : Fourier
Signal Processing Course : FourierSignal Processing Course : Fourier
Signal Processing Course : FourierGabriel Peyré
 
Lesson 29: Integration by Substition (worksheet solutions)
Lesson 29: Integration by Substition (worksheet solutions)Lesson 29: Integration by Substition (worksheet solutions)
Lesson 29: Integration by Substition (worksheet solutions)Matthew Leingang
 
Lesson 29: Integration by Substition
Lesson 29: Integration by SubstitionLesson 29: Integration by Substition
Lesson 29: Integration by SubstitionMatthew Leingang
 
TABLA DE DERIVADAS
TABLA DE DERIVADASTABLA DE DERIVADAS
TABLA DE DERIVADASEducación
 
Lesson 13: Derivatives of Logarithmic and Exponential Functions
Lesson 13: Derivatives of Logarithmic and Exponential FunctionsLesson 13: Derivatives of Logarithmic and Exponential Functions
Lesson 13: Derivatives of Logarithmic and Exponential FunctionsMatthew Leingang
 

Mais procurados (17)

Chapter4 tf
Chapter4 tfChapter4 tf
Chapter4 tf
 
Fourier series
Fourier seriesFourier series
Fourier series
 
Ism et chapter_2
Ism et chapter_2Ism et chapter_2
Ism et chapter_2
 
23 industrial engineering
23 industrial engineering23 industrial engineering
23 industrial engineering
 
Journey to structure from motion
Journey to structure from motionJourney to structure from motion
Journey to structure from motion
 
Digfilt
DigfiltDigfilt
Digfilt
 
C Language Unit-3
C Language Unit-3C Language Unit-3
C Language Unit-3
 
Unit3 jwfiles
Unit3 jwfilesUnit3 jwfiles
Unit3 jwfiles
 
CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10
 
Lesson 8: Basic Differentiation Rules (Section 21 slides)
Lesson 8: Basic Differentiation Rules (Section 21 slides)Lesson 8: Basic Differentiation Rules (Section 21 slides)
Lesson 8: Basic Differentiation Rules (Section 21 slides)
 
Signal Processing Course : Fourier
Signal Processing Course : FourierSignal Processing Course : Fourier
Signal Processing Course : Fourier
 
Lesson 29: Integration by Substition (worksheet solutions)
Lesson 29: Integration by Substition (worksheet solutions)Lesson 29: Integration by Substition (worksheet solutions)
Lesson 29: Integration by Substition (worksheet solutions)
 
Lesson 29: Integration by Substition
Lesson 29: Integration by SubstitionLesson 29: Integration by Substition
Lesson 29: Integration by Substition
 
TABLA DE DERIVADAS
TABLA DE DERIVADASTABLA DE DERIVADAS
TABLA DE DERIVADAS
 
Lesson 13: Derivatives of Logarithmic and Exponential Functions
Lesson 13: Derivatives of Logarithmic and Exponential FunctionsLesson 13: Derivatives of Logarithmic and Exponential Functions
Lesson 13: Derivatives of Logarithmic and Exponential Functions
 
Sect1 2
Sect1 2Sect1 2
Sect1 2
 
Midsem sol 2013
Midsem sol 2013Midsem sol 2013
Midsem sol 2013
 

Destaque

Arithmetic coding
Arithmetic codingArithmetic coding
Arithmetic codingVikas Goyal
 
An Efficient encryption using Data compression towards Steganography,introduc...
An Efficient encryption using Data compression towards Steganography,introduc...An Efficient encryption using Data compression towards Steganography,introduc...
An Efficient encryption using Data compression towards Steganography,introduc...prashantdahake
 
Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)anithabalaprabhu
 
Discrete cosine transform
Discrete cosine transform   Discrete cosine transform
Discrete cosine transform Rashmi Karkra
 
Discrete cosine transform
Discrete cosine transformDiscrete cosine transform
Discrete cosine transformaniruddh Tyagi
 

Destaque (6)

Arithmetic coding
Arithmetic codingArithmetic coding
Arithmetic coding
 
Arithmetic Coding
Arithmetic CodingArithmetic Coding
Arithmetic Coding
 
An Efficient encryption using Data compression towards Steganography,introduc...
An Efficient encryption using Data compression towards Steganography,introduc...An Efficient encryption using Data compression towards Steganography,introduc...
An Efficient encryption using Data compression towards Steganography,introduc...
 
Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)
 
Discrete cosine transform
Discrete cosine transform   Discrete cosine transform
Discrete cosine transform
 
Discrete cosine transform
Discrete cosine transformDiscrete cosine transform
Discrete cosine transform
 

Semelhante a Ch 04 Arithmetic Coding ( P P T)

03 truncation errors
03 truncation errors03 truncation errors
03 truncation errorsmaheej
 
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 matrixRumah Belajar
 
Unit 1 Operation on signals
Unit 1  Operation on signalsUnit 1  Operation on signals
Unit 1 Operation on signalsDr.SHANTHI K.G
 
數學測試
數學測試數學測試
數學測試s9007912
 
Interpolation techniques - Background and implementation
Interpolation techniques - Background and implementationInterpolation techniques - Background and implementation
Interpolation techniques - Background and implementationQuasar 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 bookJosé Antonio PAYANO YALE
 
Lesson20 Tangent Planes Slides+Notes
Lesson20   Tangent Planes Slides+NotesLesson20   Tangent Planes Slides+Notes
Lesson20 Tangent Planes Slides+NotesMatthew Leingang
 

Semelhante a Ch 04 Arithmetic Coding ( P P T) (20)

Taylor problem
Taylor problemTaylor problem
Taylor problem
 
03 truncation errors
03 truncation errors03 truncation errors
03 truncation errors
 
Amth250 octave matlab some solutions (1)
Amth250 octave matlab some solutions (1)Amth250 octave matlab some solutions (1)
Amth250 octave matlab some solutions (1)
 
Ism et chapter_3
Ism et chapter_3Ism et chapter_3
Ism et chapter_3
 
Ism et chapter_3
Ism et chapter_3Ism et chapter_3
Ism et chapter_3
 
Ism et chapter_3
Ism et chapter_3Ism et chapter_3
Ism et chapter_3
 
Assignment6
Assignment6Assignment6
Assignment6
 
02 2d systems matrix
02 2d systems matrix02 2d systems matrix
02 2d systems matrix
 
Unit 1 Operation on signals
Unit 1  Operation on signalsUnit 1  Operation on signals
Unit 1 Operation on signals
 
Math report
Math reportMath report
Math report
 
數學測試
數學測試數學測試
數學測試
 
Interpolation techniques - Background and implementation
Interpolation techniques - Background and implementationInterpolation techniques - Background and implementation
Interpolation techniques - Background and implementation
 
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...
 
Chapter3 laplace
Chapter3 laplaceChapter3 laplace
Chapter3 laplace
 
1010n3a
1010n3a1010n3a
1010n3a
 
Varian, microeconomic analysis, solution book
Varian, microeconomic analysis, solution bookVarian, microeconomic analysis, solution book
Varian, microeconomic analysis, solution book
 
Ch33 11
Ch33 11Ch33 11
Ch33 11
 
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) - ...
 
Imc2017 day2-solutions
Imc2017 day2-solutionsImc2017 day2-solutions
Imc2017 day2-solutions
 
Lesson20 Tangent Planes Slides+Notes
Lesson20   Tangent Planes Slides+NotesLesson20   Tangent Planes Slides+Notes
Lesson20 Tangent Planes Slides+Notes
 

Mais de anithabalaprabhu (20)

Shannon Fano
Shannon FanoShannon Fano
Shannon Fano
 
Compression
CompressionCompression
Compression
 
Datacompression1
Datacompression1Datacompression1
Datacompression1
 
Speech Compression
Speech CompressionSpeech Compression
Speech Compression
 
Z24 4 Speech Compression
Z24   4   Speech CompressionZ24   4   Speech Compression
Z24 4 Speech Compression
 
Dictor
DictorDictor
Dictor
 
Dictionary Based Compression
Dictionary Based CompressionDictionary Based Compression
Dictionary Based Compression
 
Module 4 Arithmetic Coding
Module 4 Arithmetic CodingModule 4 Arithmetic Coding
Module 4 Arithmetic Coding
 
Compression Ii
Compression IiCompression Ii
Compression Ii
 
Lassy
LassyLassy
Lassy
 
Compression Ii
Compression IiCompression Ii
Compression Ii
 
Lossy
LossyLossy
Lossy
 
Planning
PlanningPlanning
Planning
 
Lossless
LosslessLossless
Lossless
 
Losseless
LosselessLosseless
Losseless
 
Lec32
Lec32Lec32
Lec32
 
Lec5 Compression
Lec5 CompressionLec5 Compression
Lec5 Compression
 
Huffman Student
Huffman StudentHuffman Student
Huffman Student
 
Huffman Encoding Pr
Huffman Encoding PrHuffman Encoding Pr
Huffman Encoding Pr
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 

Último

General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 

Último (20)

General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 

Ch 04 Arithmetic Coding ( P P T)

  • 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