The use and Usefulness of Fibonacci Codes Shmuel
The use and Usefulness of Fibonacci Codes Shmuel Tomi Klein Bar Ilan University Invited talk - PSC 2016
Fibonacci numbers for 0 1 1 2 3 5 8 13 21 34 55 89 144 … Basis elements of a numeration system
Binary representations of integers Basis elements: 45 = 128 64 32 16 0 0 1 0 55 34 21 13 45 = 0 1 0 0 Fibonacci: 8 1 No adjacent 1’s 8 1 4 1 2 0 1 1 5 0 3 1 2 0 1 0
standard Fibonacci Codeword length: Probability of 1 -bit: Avg # of 1 -bits:
Fib 1 standar d 1 2 10 10 3 11 100 1 11 3 6 4 100 101 5 101 1000 1 1011 11 110 6 110 1001 7 111 1010 8 10000 9 1001 10 1010 10010 11 10100 12 1100 10101 13 1101 100000 14 1110 100001 1 Problem: concatenations 1101111110 0001 1011 0110 1 10100 1001 1111010011001 1 serves as comma
Technical Problem: code is UD but not instantaneous 11011111110 | 11 | 10 1101 | 110 Reverse codewords After appending a 1 Get a Prefix code Fib code 1 1 11 2 10 011 3 100 0011 4 1011 5 1000 00011 6 10011 7 1010 01011 8 1000011 9 100011 10 10010 010011 11 10100 001011 12 101011 13 10000011 14 1000011
Fib code 1 1 11 2 10 011 3 100 0011 4 1011 5 1000 00011 6 10011 7 1010 01011 8 1000011 9 100011 10 10010 010011 11 10100 001011 12 101011 13 10000011 14 1000011
Fibonacci numbers of order for Binary representation: number of consecutive 1 s < m
Fibonacci numbers of order m General Term 1 2 3 4 5 2. 724 1. 618 1 n 2 3 5 8 13 21 34 55 3. 618 1. 839 1 n 2 4 7 13 24 44 81 149 4 10 8 15 29 56 208 8 4. 566 1. 928 1 n 2 Fibonacci representation: 6 7 8 9 1 2 4 7 13 24 44 81 67 = 1 1 0
index Fib 2 Fib 3 Fib 4 1 11 1111 2 01111 3 001111 4 101111 5 0001111 6 1001111 7 0101111 8 000011 1101111 9 100011 00001111 10 010011 10001111 11 001011 01001111 12 101011 11001111 13 0000011 00101111 14 1000011 10101111 15 0100011 01101111 16 0010011 00000111 11101111 There are codewords of length
Usefulness of Fibonacci Codes Better compression than dense codes More robust than Huffman codes Bitmap compression Modular exponentiation Rewriting on flash memory
Better compression than dense codes Binary character Huffman Binary word-based Huffman 256 -ary word-based Huffman Tagged Huffman End tagged Huffman (s, c) dense codes
Compression Efficiency bits codeword length 20 - log p 10 ETDC Fib 2 Fib 3 0 1 16 256 4096 65536
Compression Efficiency bits average codeword length for Zipf 22 18 14 10 ETDC Fib 2 6 Fib 3 1 1000000
Compression Efficiency Languag size Fib 2 Fib 3 Fib 4 e English 289 French 439 Hebrew 297 Artificial 1000 12. 3 6 11. 3 1 15. 0 0 15. 0 4 11. 7 7 10. 9 4 13. 8 9 13. 8 7 12. 3 7 11. 6 0 14. 3 6 14. 3 2 ETDC (s, c) 12. 9 7 11. 9 9 14. 9 8 15. 2 6 12. 7 5 11. 8 1 14. 8 1 15. 1 6
More robust than Huffman codes Bit-flips 1 or 2 codewords lost for fixed length, TH, SCDC, Fibm. No propagation for TH, SCDC, like var length Huffman all the suffix may be lost Insertions Deletions Fibm are immune because codeword ending is explicit
Robustness Fib 3 In the beginning God created the heaven and the before And the earth was without form and void and darkness was Huf In the beginning God created the heaven and the father thy of upon was without form and void and darkness was In the beginning God created the sin And of the Jacob SCDC against called thine mouth whom to hands with to sword
Bitmap compression Sparse bitmaps: occurrence maps in IR systems Pictures, faxes 0000001000001001000001100000000000000010000000000000 Compression: Indices, run-length Huffman Blocks 256 elements Add runs of 0 -blocks
Bitmap compression runs of 0 -blocks: all Too many elements Represent each run-length as a sum of basis elements Pow 2 1 2 4 8 16 32 … 2. 16 on avg Fibonacci 1 2 3 5 8 13 21 … 1. 83 on avg Compression factor IR maps rando picture m Huffman 6. 57 6. 59 5. 28 + pow 2 17. 04 14. 66 8. 33 + Fib 17. 36 14. 97 8. 77
Modular exponentiation a, m and N very large Prepare log m basis elements Multiply those corresponding to 1 -bits
Modular exponentiation Alternative: use Fibonacci instead of standard Prepare log m basis elements Multiply those corresponding to 1 -bits # of elements: log 2 m # of multiplications: 0. 5 log 2 m log m = 1. 44 log 2 m 0. 398 log 2 m
Main constraint of flash: changing a Rewriting on WOM- write once memory bit-value 0 to 1 easy 1 to 0 only in blocks Rewriting Code Rivest-Shamir: 3 bits encode 4 values ratio 1. 333
Idea: Use Fibonacci in first round No adjacent 1’s Every 1 is followed by 0 Use these 0 -bits to encode second round
Encoding 0 Consider data block as binary number 1 Recode block in Fibonacci representation 2 Add 1 s without violating constraint 3 Use bit following 1 s in second writing round Encode NQx = 5, 132, 664 and then 7777 = 0111100001 1 0 10100010 01010000 01001010 00010100 2 0 1010 0101 010010100 3 0 1010 0101 010010100 0 10111111 011101010 10010110 Data: 24 + 14 = 38 bits Ratio: 38 / 33 = 1. 152
Decoding 0 10111111 011101010 10010110 I nitial S S eparator D ata E xtension 0, 1 1 I 1 1 0 D 0 E
Compression ratio 1. 028 to average To add flexibility 1. 194 1. 145 varying tradeoffs between writing rounds for 36 = 41 28 19 13 9 6 4 3 2 1 0 0 0 1 0 At least m - 1 zeros between 1’s
Higher order Every 1 is followed by several 0 Compression ratio Prob 1 -bit best avg worst 2 0. 276 1. 194 1. 145 1. 028 3 0. 195 1. 218 1. 127 0. 952 4 0. 151 1. 215 1. 098 0. 894 5 0. 124 1. 206 1. 072 0. 850
Encoding with higher order Boosting RS to 3 rounds Encode RS table 00 000 111 01 100 011 10 010 101 11 001 110 NQx = 5, 132, 664 and then 55, 555 and then 44, 444 1 10001001 00100001 00000100 10010001 00100100 2 10001001 00100001 0010010001 00100100 3 10001111 00101001 0110010001 00100101 11 10 01 00 00 00 11 11 01 10 Data: 10 24 + 16 = 56 bits Ratio: 56 01 / 40 = 1. 4 11 00 11001111001 0110 1101 11101111
Conclusion “The Fibonacci number system (so -called by Knuth) is another remarkable and remarkably useless number system” N. R. Scott, Computer Number Systems & Arithmetic (1985) p. 211
References Fraenkel A. S. , Klein S. T. , Novel Compression of Sparse Bit-Strings Combinatorial Algorithms on Words, NATO ASI Series Vol F 12, Springer Verlag, Berlin (1985) 169 -183. Fraenkel A. S. , Klein S. T. , Robust Universal Complete Codes for Transmission and Compression, Discrete Applied Mathematics 64 (1996) 31 -55. Klein S. T. , Should one always use repeated squaring for modular exponentiation? , Information Processing Letters 106(6) (2008) 232 -237. Klein S. T. , Kopel Ben-Nissan M. , On the Usefulness of Fibonacci Compression Codes, The Computer Journal 53 (2010) 701 -716. Klein S. T. , Shapira D. , Codes for enhancing the repeated use of Flash Memory, Data Compression Conference DCC (2014).
The use and Usefulness of Fibonacci Codes Shmuel Tomi Klein Bar Ilan University Invited talk - PSC 2016
Applications of a Useless Number System Shmuel Tomi Klein Bar Ilan University Invited talk - PSC 2016
Thank you !
- Slides: 33