Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Elias delta coding
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Encoding == To code a number ''X'' β₯ 1: # Let ''N'' = βlog<sub>2</sub> ''X''β; be the highest power of 2 in ''X'', so 2<sup>''N''</sup> β€ ''X'' < 2<sup>''N''+1</sup>. # Let ''L'' = βlog<sub>2</sub> ''N''+1β be the highest power of 2 in ''N''+1, so 2<sup>''L''</sup> β€ ''N''+1 < 2<sup>''L''+1</sup>. # Write ''L'' zeros, followed by # the ''L''+1-bit binary representation of ''N''+1, followed by # all but the leading bit (i.e. the last ''N'' bits) of ''X''. An equivalent way to express the same process: #Separate ''X'' into the highest power of 2 it contains (2<sup>''N''</sup>) and the remaining ''N'' binary digits. #Encode ''N''+1 with [[Elias gamma coding]]. #Append the remaining ''N'' binary digits to this representation of ''N''+1. To represent a number <math>x</math>, Elias delta (Ξ΄) uses <math>\lfloor \log_2(x) \rfloor + 2 \lfloor \log_2 (\lfloor \log_2(x) \rfloor +1) \rfloor + 1</math> bits.<ref name="Elias"/>{{rp|200}} This is useful for very large integers, where the overall encoded representation's bits end up being fewer [than what one might obtain using [[Elias gamma coding]]] due to the <math>\log_2 (\lfloor \log_2(x) \rfloor +1)</math> portion of the previous expression. The code begins, using <math>\gamma'</math> instead of <math>\gamma</math>: {| class="wikitable" ! Number !! N !! N+1 !! Ξ΄ encoding !! Implied probability |- | 1 = 2<sup>0</sup> || 0 || 1 || <code>1</code> || 1/2 |- |colspan=5| |- | 2 = 2<sup>1</sup> + ''0'' || 1 || 2 || <code>0 1 0 ''0''</code> || 1/16 |- | 3 = 2<sup>1</sup> + ''1'' || 1 || 2 || <code>0 1 0 ''1''</code> || 1/16 |- |colspan=5| |- | 4 = 2<sup>2</sup> + ''0'' || 2 || 3 || <code>0 1 1 ''00''</code> || 1/32 |- | 5 = 2<sup>2</sup> + ''1'' || 2 || 3 || <code>0 1 1 ''01''</code> || 1/32 |- | 6 = 2<sup>2</sup> + ''2'' || 2 || 3 || <code>0 1 1 ''10''</code> || 1/32 |- | 7 = 2<sup>2</sup> + ''3'' || 2 || 3 || <code>0 1 1 ''11''</code> || 1/32 |- |colspan=5| |- | 8 = 2<sup>3</sup> + ''0'' || 3 || 4 || <code>00 1 00 ''000''</code> || 1/256 |- | 9 = 2<sup>3</sup> + ''1'' || 3 || 4 || <code>00 1 00 ''001''</code> || 1/256 |- | 10 = 2<sup>3</sup> + ''2'' || 3 || 4 || <code>00 1 00 ''010''</code> || 1/256 |- | 11 = 2<sup>3</sup> + ''3'' || 3 || 4 || <code>00 1 00 ''011''</code> || 1/256 |- | 12 = 2<sup>3</sup> + ''4'' || 3 || 4 || <code>00 1 00 ''100''</code> || 1/256 |- | 13 = 2<sup>3</sup> + ''5'' || 3 || 4 || <code>00 1 00 ''101''</code> || 1/256 |- | 14 = 2<sup>3</sup> + ''6'' || 3 || 4 || <code>00 1 00 ''110''</code> || 1/256 |- | 15 = 2<sup>3</sup> + ''7'' || 3 || 4 || <code>00 1 00 ''111''</code> || 1/256 |- |colspan=5| |- | 16 = 2<sup>4</sup> + ''0'' || 4 || 5 || <code>00 1 01 ''0000''</code> || 1/512 |- | 17 = 2<sup>4</sup> + ''1'' || 4 || 5 || {{nowrap|<code>00 1 01 ''0001''</code>}} || 1/512 |} To decode an Elias delta-coded integer: #Read and count zeros from the stream until you reach the first one. Call this count of zeros ''L''. #Considering the one that was reached to be the first digit of an integer, with a value of 2<sup>''L''</sup>, read the remaining ''L'' digits of the integer. Call this integer ''N''+1, and subtract one to get ''N''. #Put a one in the first place of our final output, representing the value 2<sup>''N''</sup>. #Read and append the following ''N'' digits. Example: 001010011 1. 2 leading zeros in 001 2. read 2 more bits i.e. 00101 3. decode N+1 = 00101 = 5 4. get N = 5 β 1 = 4 remaining bits for the complete code i.e. '0011' 5. encoded number = 2<sup>4</sup> + 3 = 19 This code can be generalized to zero or negative integers in the same ways described in [[Elias gamma coding#Generalizations|Elias gamma coding]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)