ebooksgratis.com

See also ebooksgratis.com: no banners, no cookies, totally FREE.

CLASSICISTRANIERI HOME PAGE - YOUTUBE CHANNEL
Privacy Policy Cookie Policy Terms and Conditions
Fibonacci coding - Wikipedia, the free encyclopedia

Fibonacci coding

From Wikipedia, the free encyclopedia

Numeral systems by culture
Hindu-Arabic numerals
Indian
Eastern Arabic
Khmer
Indian family
Brahmi
Thai
East Asian numerals
Chinese
Suzhou
Counting rods
Japanese
Korean 
Alphabetic numerals
Abjad
Armenian
Cyrillic
Ge'ez
Hebrew
Greek (Ionian)
Āryabhaṭa
 
Other systems
Attic
Babylonian
Egyptian
Etruscan
Mayan
Roman
Urnfield
List of numeral system topics
Positional systems by base
Decimal (10)
2, 4, 8, 16, 32, 64
1, 3, 9, 12, 20, 24, 30, 36, 60, more…
v  d  e

In mathematics, Fibonacci coding is a universal code which encodes positive integers into binary code words. All tokens end with "11" and have no "11" before the end.

The formula used to generate Fibonacci codes is:

  1. N = \sum_{i=0}^k d(i) F(i)
  2. d(i) = 1 \Rightarrow d(i+1) = 0\,\!

where F(i) is the ith Fibonacci number. No two adjacent coefficients d(i) can be 1.

The code begins as follows:

Symbol Fibonacci representation Fibonacci code
1 F(1) 1 11
2 F(2) 2 011
3 F(3) 4 0011
4 F(1) + F(3) 5 1011
5 F(4) 8 00011
6 F(1) + F(4) 9 10011
7 F(2) + F(4) 10 01011
8 F(5) 16 000011

The Fibonacci code is closely related to Fibonacci representation, a positional numeral system sometimes used by mathematicians. The Fibonacci code for a particular integer is exactly that of the integer's Fibonacci representation, except with the order of its digits reversed and an additional "1" appended to the end.

To encode an integer X:

  1. Find the largest Fibonacci number equal to or less than X; subtract this number from X, keeping track of the remainder.
  2. If the number we subtracted was the Nth unique Fibonacci number, put a one in the Nth digit of our output.
  3. Repeat the previous steps, substituting our remainder for X, until we reach a remainder of 0.
  4. Place a one after the last naturally-occurring one in our output.

To decode a token in the code, remove the last "1", assign the remaining bits the values 1,2,3,5,8,13... (the Fibonacci numbers), and add the "1" bits.

[edit] Comparison with other universal codes

Fibonacci coding has a useful property that sometimes makes it attractive in comparison to other universal codes: it is easier to recover data from a damaged stream. With most other universal codes, if a single bit is altered, none of the data that comes after it will be correctly read. With Fibonacci coding, on the other hand, a changed bit may cause one token to be read as two, or cause two tokens to be read incorrectly as one, but reading a "0" from the stream will stop the errors from propagating further. Since the only stream that has no "0" in it is a stream of "11" tokens, the total edit distance between a stream damaged by a single bit error and the original stream is at most three.

This approach - encoding using sequence of symbols, in which some patterns (like "11") are forbidden, can be freely generalized[1].

[edit] See also

Languages


aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -