Fibonacci coding

In mathematics and computing, Fibonacci coding is a universal code[citation needed] which encodes positive integers into binary code words. It is one example of representations of integers based on Fibonacci numbers. Each code word ends with "11" and contains no other instances of "11" before the end.

The Fibonacci code is closely related to the Zeckendorf representation, a positional numeral system that uses Zeckendorf's theorem and has the property that no number has a representation with consecutive 1s. The Fibonacci code word for a particular integer is exactly the integer's Zeckendorf representation with the order of its digits reversed and an additional "1" appended to the end.

Definition

For a number , if represent the digits of the code word representing then we have:

where F(i) is the ith Fibonacci number, and so F(i+2) is the ith distinct Fibonacci number starting with . The last bit is always an appended bit of 1 and does not carry place value.

It can be shown that such a coding is unique, and the only occurrence of "11" in any code word is at the end i.e. d(k−1) and d(k). The penultimate bit is the most significant bit and the first bit is the least significant bit. Also leading zeros cannot be omitted as they can in e.g. decimal numbers.

The first few Fibonacci codes are shown below, and also their so-called implied probability, the value for each number that has a minimum-size code in Fibonacci coding.

Symbol Fibonacci representation Fibonacci code word Implied probability
1 11 1/4
2 011 1/8
3 0011 1/16
4 1011 1/16
5 00011 1/32
6 10011 1/32
7 01011 1/32
8 000011 1/64
9 100011 1/64
10 010011 1/64
11 001011 1/64
12 101011 1/64
13 0000011 1/128
14 1000011 1/128

To encode an integer N:

  1. Find the largest Fibonacci number equal to or less than N; subtract this number from N, keeping track of the remainder.
  2. If the number subtracted was the ith Fibonacci number F(i), put a 1 in place i−2 in the code word (counting the left most digit as place 0).
  3. Repeat the previous steps, substituting the remainder for N, until a remainder of 0 is reached.
  4. Place an additional 1 after the rightmost digit in the code word.

To decode a code word, remove the final "1", assign the remaining the values 1,2,3,5,8,13... (the Fibonacci numbers) to the bits in the code word, and sum the values of the "1" bits.

Comparison with other universal codes

Fibonacci coding has a useful property that sometimes makes it attractive in comparison to other universal codes: it is an example of a self-synchronizing code, making it 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]

Example

The following table shows that the number 65 is represented in Fibonacci coding as 0100100011, since 65 = 2 + 8 + 55. The first two Fibonacci numbers (0 and 1) are not used, and an additional 1 is always appended.

Generalizations

The Fibonacci encodings for the positive integers are binary strings that end with "11" and contain no other instances of "11". This can be generalized to binary strings that end with N consecutive 1's and contain no other instances of N consecutive 1's. For instance, for N = 3 the positive integers are encoded as 111, 0111, 00111, 10111, 000111, 100111, 010111, 110111, 0000111, 1000111, 0100111, …. In this case, the number of encodings as a function of string length is given by the sequence of Tribonacci numbers.

For general constraints defining which symbols are allowed after a given symbol, the maximal information rate can be obtained by first finding the optimal transition probabilities using maximal entropy random walk, then use entropy coder (with switched encoder with decoder) to encode a message as a sequence of symbols fulfilling the found optimal transition probabilities.

See also

References

  1. ^ Duda, Jarek (2007). "Optimal encoding on discrete lattice with translational invariant constrains using statistical algorithms". arXiv:0710.3861 [cs.IT].

Further reading

  • Stakhov, A. P. (2009). The Mathematics of Harmony: From Euclid to Contemporary Mathematics and Computer Science. Singapore: World Scientific Publishing.

Read other articles:

Maro Sebo UluKecamatanKantor Kecamatan Maro Sebo Ulu, Kabupaten Batang Hari, JambiNegara IndonesiaProvinsiJambiKabupatenBatanghariPemerintahan • CamatIsmail. S.PdPopulasi (2020) • Total39.588 jiwaKode pos36652Kode Kemendagri15.04.06 Kode BPS1504011 Desa/kelurahan16 desa1 kelurahan Sungai Batanghari di Desa Kampung Baru, Maro Sebo Ulu sekitar tahun 1910-an. Maro Sebo Ulu adalah sebuah kecamatan di Kabupaten Batanghari, Jambi, Indonesia. Desa/Kelurahan Simp. Sunga…

Emir Spahić Informasi pribadiNama lengkap Emir SpahićTanggal lahir 18 Agustus 1980 (umur 43)Tempat lahir Dubrovnik, YugoslaviaTinggi 1,83 m (6 ft 0 in)Posisi bermain Bek tengahKarier junior Čelik Zenica FK Krajina CazinKarier senior*Tahun Tim Tampil (Gol)1998–1999 Čelik Zenica 0 (0)1999–2001 GOŠK Dubrovnik 22 (0)2001–2004 NK Zagreb 38 (2)2004–2005 Shinnik Yaroslavl 26 (6)2005–2006 Torpedo Moscow 15 (0)2006–2009 Lokomotiv Moscow 63 (3)2009–2011 Montpellier 5…

Solar park in Zhongwei, China Tengger Desert Solar ParkCountryChinaCoordinates37°33′43.2″N 105°2′28.68″E / 37.562000°N 105.0413000°E / 37.562000; 105.0413000StatusOperationalSolar farmTypeStandard PVPower generationNameplate capacity1.547 GWExternal linksCommonsRelated media on Commons[edit on Wikidata] Tengger Desert Solar Park is the sixth-largest photovoltaic plant in the world as of December, 2021. It is located in Zh…

Artikel ini mungkin terdampak dengan peristiwa terkini: Invasi Rusia ke Ukraina 2022. Informasi di halaman ini bisa berubah setiap saat. Distrik Federal Krimea Крымский федеральный округКримський федеральний округDistrik federal di RusiaLokasi Distrik Federal Krimea di RussiaNegara RusiaDidirikan21 Maret 2014Pusat administratifSimferopolPemerintahan • Duta kepresidenanOleg BelaventsevLuas • Jumlah27.000 km2 (10,00…

Aşağı AtucMunisipalitasAşağı AtucKoordinat: Koordinat: 41°27′N 48°34′E / 41.450°N 48.567°E / 41.450; 48.567Negara AzerbaijanRayonQubaPopulasi (2009) • Total2.236Zona waktuUTC+4 (AZT) • Musim panas (DST)UTC+5 (AZT) Aşağı Atuc adalah sebuah desa dan munisiplaitas di Rayon Quba, Azerbaijan. Referensi Wikimedia Commons memiliki media mengenai Aşağı Atuc. lbsRayon QubaIbu kota: Quba Adur Afurca Ağbil Alekseyevka Alıc Alpa…

Liang AnggangDesaKantor desa Liang AnggangPeta lokasi Desa Liang AnggangNegara IndonesiaProvinsiKalimantan SelatanKabupatenTanah LautKecamatanBati-BatiKode pos70852Kode Kemendagri63.01.05.2004 Luas2.650 haJumlah penduduk3.725 jiwaKepadatan... jiwa/km² Liang Anggang adalah salah satu desa di Kecamatan Bati-Bati, Kabupaten Tanah Laut, Provinsi Kalimantan Selatan, Indonesia. Disini terdapat banyak perusahaan Industri seperti makanan, pakan ternak, dll. lbsKecamatan Bati-Bati, Kabupaten Tanah …

Cinema of Pakistan List of Pakistani films Pakistani Animation Highest Grossing Pre 1950 1950s 1950 1951 1952 1953 19541955 1956 1957 1958 1959 1960s 1960 1961 1962 1963 19641965 1966 1967 1968 1969 1970s 1970 1971 1972 1973 19741975 1976 1977 1978 1979 1980s 1980 1981 1982 1983 19841985 1986 1987 1988 1989 1990s 1990 1991 1992 1993 19941995 1996 1997 1998 1999 2000s 2000 2001 2002 2003 20042005 2006 2007 2008 2009 2010s 2010 2011 2012 2013 20142015 2016 2017 2018 2019 2020s 2020 2021 2022 2023 …

Dance party For other uses, see Rave (disambiguation). RaveDJ Sven Väth mixes tracks for a crowd of dancers at Amnesia, an Ibiza nightclub, in 2013.General InformationLocationWorldwideTypes of street rave danceHakkenPara ParaRebolationMelbourne ShuffleEventsMusic festivalElectronic dance music festivaltechnoparadesAcid house partydoofOrchestraTrance festivalNatureHouse partyTrap musicTeknivalAlgoraveFree festivalFree partyCircuit partyConcert tourTopicsElectronic dance musicNightclubSmileyDisc …

Uzbekistan Airways IATA ICAO Kode panggil HY[1] UZB[1] UZBEKISTAN[1] Didirikan28 Januari 1992 (1992-01-28)Mulai beroperasi31 Mei 1992 (1992-05-31)PenghubungTashkent International AirportProgram penumpang setiaUz Air PlusArmada65 (+6 dalam pemesanan)Tujuan58SloganNational airline of UzbekistanPerusahaan indukGovernment of UzbekistanKantor pusatTashkent, UzbekistanTokoh utamaValeriy Nikolaevich Tyan(CEO)[butuh rujukan]Dmitriy Davidov (CFO)[butuh rujuka…

كأس ليتوانيا 2011–12 تفاصيل الموسم كأس ليتوانيا  النسخة 23  البلد ليتوانيا  التاريخ بداية:5 يوليو 2011  نهاية:20 مايو 2012  المنظم اتحاد ليتوانيا لكرة القدم  البطل نادي جالغيريس  عدد المشاركين 65   كأس ليتوانيا 2010–11  كأس ليتوانيا 2012–13  [لغات أخرى]‏  تعد…

درابيتسونا    خريطة الموقع تقسيم إداري البلد اليونان  [1] خصائص جغرافية إحداثيات 37°56′48″N 23°37′30″E / 37.94666667°N 23.625°E / 37.94666667; 23.625   الارتفاع 0 متر  السكان التعداد السكاني 13815 (resident population of Greece) (2021)[2]13335 (resident population of Greece) (2001)13116 (resident population of Greece) (1991)139…

1850 minstrel song by Stephen FosterCamptown RacesOriginal sheet music coverSong by Stephen FosterWritten1850PublishedFebruary 1850GenreMinstrel show 'De Camptown Races' or 'Gwine to Run All Night' (nowadays popularly known as 'Camptown Races') is a minstrel song by American Romantic composer Stephen Foster. It was published in February 1850 by F. D. Benteen and was introduced to the American mainstream by Christy's Minstrels, eventually becoming one of the most popular folk/Americana tunes of t…

  لمعانٍ أخرى، طالع جيمس ويب (توضيح). جيمس ويب معلومات شخصية اسم الولادة (بالإنجليزية: James Ruffin Webb)‏  الميلاد 4 أكتوبر 1909 [1]  دنفر[1]  الوفاة 28 سبتمبر 1974 (64 سنة)   نيويورك[2]،  ولوس أنجلوس[3]  مواطنة الولايات المتحدة  الحياة العملية المدرسة الأم …

Eurovision Song Contest 2021Country AzerbaijanNational selectionSelection processInternal selectionSelection date(s)Artist: 20 March 2020Song: 15 March 2021Selected entrantEfendiSelected songMata HariSelected songwriter(s)Amy van der WelJosh EarlLuuk van BeersTony CornelissenFinals performanceSemi-final resultQualified (8th, 138 points)Final result20th, 65 pointsAzerbaijan in the Eurovision Song Contest ◄2020 • 2021 • 2022► Azerbaijan participated …

This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.Find sources: GCR Class 8K – news · newspapers · books · scholar · JSTOR (February 2015) GCR Classes 8K and 8MNo. 3758 at Whitemoor DepotType and originPower typeSteamDesignerJohn G. RobinsonBuilder8K: GCR Gorton Works (56) Kitson & Co. (20) North Brit…

Questa voce o sezione sull'argomento edizioni di competizioni calcistiche non cita le fonti necessarie o quelle presenti sono insufficienti. Puoi migliorare questa voce aggiungendo citazioni da fonti attendibili secondo le linee guida sull'uso delle fonti. Segui i suggerimenti del progetto di riferimento. Questa voce o sezione sull'argomento Competizioni calcistiche non è ancora formattata secondo gli standard. Commento: Si invita a seguire il modello di voce Contribuisci a migliorarl…

John McIntirePersonal detailsBorn(1759-10-15)October 15, 1759Alexandria, VirginiaDiedJuly 29, 1815(1815-07-29) (aged 55)Zanesville, OhioResting placePioneer Hill Cemetery, Zanesville John McIntire (October 15, 1759 – July 29, 1815) was the founder of the city of Zanesville, Ohio. McIntire was born in Alexandria, Virginia. He married Sarah Zane, the daughter of Colonel Ebenezer Zane, in December 1789. McIntire founded Zanesville in 1797 on land deeded by Colonel Zane. One family history cl…

2022 Indian Tamil-language action thriller film MaaranOfficial release posterDirected byKarthick NarenScreenplay byKarthick NarenSuhas-SharfuVivekStory byKarthick NarenProduced bySendhil ThyagarajanArjun ThyagarajanStarringDhanush Smruthi Venkat Malavika MohananCinematographyVivekanand SanthoshamEdited byPrasanna G. K.Music byG. V. Prakash KumarProductioncompanySathya Jyothi FilmsDistributed byDisney+ HotstarRelease date 11 March 2022 (2022-03-11) Running time130 minutesCountryInd…

Castle of Voltaire in Ferney-Voltaire, France The Château de Voltaire is located in Ferney-Voltaire (Ain) in France, close to the border with Switzerland and the city of Geneva. It was Voltaire’s home between 1761 and 1778. It was listed as a historical monument in 1958 and acquired by the French State in 1999. History to 1778 There are traces of an older manor house dating from the fourteenth century. In the fifteenth century the Duke of Savoy established a seigneury here. The domain was acq…

Berthold LaskerBertold (kanan) dan Emanuel Lasker menganalisis papan catur pada tahun 1908 (foto oleh Frank Eugene)Nama lengkapJonathan Berthold LaskerAsal negara JermanLahir(1860-12-31)31 Desember 1860Berlinchen, Jerman(kini Barlinek, Polandia)Meninggal19 Oktober 1928(1928-10-19) (umur 67) Berthold Lasker, Else Lasker-Schüler, Anna Lindwurm-Lindner, Franz Lindwurm-Lindner pada sekitar tahun 1900 Berthold Lasker (bernama lahir Jonathan Berthold Barnett)[1] (31 Desemb…

Kembali kehalaman sebelumnya