Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Fibonacci coding

From Wikipedia, the free encyclopedia
Universal code which encodes positive integers into binary code words
This article includes a list ofgeneral references, butit lacks sufficient correspondinginline citations. Please help toimprove this article byintroducing more precise citations.(January 2013) (Learn how and when to remove this message)
Part ofa series on
Numeral systems
List of numeral systems

Inmathematics and computing,Fibonacci coding is auniversal code[1] which encodes positive integers into binarycode words. It is one example of representations of integers based onFibonacci numbers. Each code word ends with "11" and contains no other instances of "11" before the end.

The Fibonacci code is closely related to theZeckendorf representation, a positionalnumeral system that usesZeckendorf'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

[edit]

For a numberN{\displaystyle N\!}, ifd(0),d(1),,d(k1),d(k){\displaystyle d(0),d(1),\ldots ,d(k-1),d(k)\!} represent the digits of the code word representingN{\displaystyle N\!} then we have:

N=i=0k1d(i)F(i+2), and d(k1)=d(k)=1.{\displaystyle N=\sum _{i=0}^{k-1}d(i)F(i+2),{\text{ and }}d(k-1)=d(k)=1.\!}

whereF(i) is theithFibonacci number, and soF(i+2) is theith distinct Fibonacci number starting with1,2,3,5,8,13,{\displaystyle 1,2,3,5,8,13,\ldots }. The last bitd(k){\displaystyle d(k)} 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 (that is,d(k−1) andd(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 be in, for example, decimal numbers.

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

SymbolFibonacci representationFibonacci code wordImplied probability
1F(2){\displaystyle F(2)}111/4
2F(3){\displaystyle F(3)}0111/8
3F(4){\displaystyle F(4)}00111/16
4F(2)+F(4){\displaystyle F(2)+F(4)}10111/16
5F(5){\displaystyle F(5)}000111/32
6F(2)+F(5){\displaystyle F(2)+F(5)}100111/32
7F(3)+F(5){\displaystyle F(3)+F(5)}010111/32
8F(6){\displaystyle F(6)}0000111/64
9F(2)+F(6){\displaystyle F(2)+F(6)}1000111/64
10F(3)+F(6){\displaystyle F(3)+F(6)}0100111/64
11F(4)+F(6){\displaystyle F(4)+F(6)}0010111/64
12F(2)+F(4)+F(6){\displaystyle F(2)+F(4)+F(6)}1010111/64
13F(7){\displaystyle F(7)}00000111/128
14F(2)+F(7){\displaystyle F(2)+F(7)}10000111/128

To encode an integerN:

  1. Find the largestFibonacci number equal to or less thanN; subtract this number fromN, keeping track of the remainder.
  2. If the number subtracted was theith Fibonacci numberF(i), put a 1 in placei − 2 in the code word (counting the left most digit as place 0).
  3. Repeat the previous steps, substituting the remainder forN, 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... (theFibonacci numbers) to the bits in the code word, and sum the values of the "1" bits.

Comparison with other universal codes

[edit]

Fibonacci coding has a useful property that sometimes makes it attractive in comparison to other universal codes: it is an example of aself-synchronizing code, making it easier to recover data from a damaged stream. With most other universal codes, if a singlebit is altered, then 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 totaledit 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.[2]

Example

[edit]

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

011235813213455F(0)F(1)F(2)F(3)F(4)F(5)F(6)F(7)F(8)F(9)F(10)additional0100100011{\displaystyle {\begin{array}{ccccccccccc|c}\hline 0&1&1&2&3&5&8&13&21&34&55&-\\\hline F(0)&F(1)&F(2)&F(3)&F(4)&F(5)&F(6)&F(7)&F(8)&F(9)&F(10)&\scriptstyle {\text{additional}}\\\hline -&-&0&1&0&0&1&0&0&0&1&1\\\hline \end{array}}}

Generalizations

[edit]

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 withN consecutive 1s and contain no other instances ofN consecutive 1s. For instance, forN = 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 oftribonacci 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 amaximal entropy random walk, then using anentropy coder (with switched encoder and decoder) to encode a message as a sequence of symbols fulfilling the found optimal transition probabilities.

See also

[edit]

References

[edit]
  1. ^Basu, Manjusri; Prasad, Bandhu (2010-09-01)."Long range variations on the Fibonacci universal code".Journal of Number Theory.130 (9):1925–1931.doi:10.1016/j.jnt.2010.01.013.ISSN 0022-314X.
  2. ^Duda, Jarek (2007). "Optimal encoding on discrete lattice with translational invariant constrains using statistical algorithms".arXiv:0710.3861 [cs.IT].

Further reading

[edit]
  • Stakhov, A. P. (2009).The Mathematics of Harmony: From Euclid to Contemporary Mathematics and Computer Science. Singapore:World Scientific Publishing.
Lossless
type
Entropy
Dictionary
Other
Hybrid
Lossy
type
Transform
Predictive
Audio
Concepts
Codec
parts
Image
Concepts
Methods
Video
Concepts
Codec
parts
Theory
Community
People
Retrieved from "https://en.wikipedia.org/w/index.php?title=Fibonacci_coding&oldid=1307695904"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp