Elias Code
Learned in CS451.
Elias gamma code is a universal code encoding positive integers developed by Peter Elias.
Encoding x
- Let
- Write N 0s
- Write x as an N+1-bit number
- This number starts with 1.
Decoding x:
- Read 0s until a 1, call this N
- Interpret next N+1 bits as a binary number, including the 1
Does γ work well?
- Does well for term frequencies (how many times the term appears in the document)
- Does OK for gaps, too
The Elias code assumes the values are distributed by a power law: Most numbers should be small, or it doesn’t save any space.