Shannon s Informatietheorie -Informatie, Communicatie, Entropie IUW - 26 november 2014 Jan van Leeuwen Departement Informatica Universiteit Utrecht Informatieuitwisseling 26-11-2014 1
Vandaag (Vervolg netwerken ) Informatieuitwisseling Wat is een goed model voor de communicatie van informatie en het meten van de technische effectiviteit ervan? Informatie als kwantificeerbaar goed In aanvulling op informatie als data met een betekenis. Informatieuitwisseling 26-11-2014 2
Informatieuitwisseling: Drie Niveaus Warren Weaver (1894-1978) In: Shannon/Weaver 1949, p 4. Level A. How accurately can the symbols of communication be transmitted? (The technical problem.) Level B. How precisely do the transmitted symbols convey the desired meaning? (The semantic problem.) Level C. How effectively does the received meaning affect conduct in the desired way? (The effectiveness problem.) Informatieuitwisseling 26-11-2014 3
Onderdelen I. Informatie(-theorie) Van tekens naar codering Shannon-Weaver model II. Codering bij de informatiebron Prefix codes Vaste vs variabele lengte codes Stelling van Shannon: entropie III. Datacompressie: vermindering redundantie? Typen compressie (vgl college Multimedia) Huffman coding Lempel-Ziv-Welch (LZW) coding IV. Shannon s uitspraken over communicatie Capaciteiten met/zonder storing (ruis) Nabeschouwing V. Conclusies Informatieuitwisseling 26-11-2014 4
I. Informatie(-theorie) Communicatie van berichten Abstraheren van inhoud en betekenis Shannon (1948): semantic aspects of communication are irrelevant to the engineering problem. Vorm: tekst, images, video, voice, audio Shannon (1948):... binary digits, or more briefly bits, a word suggested by J.W. Tukey. Wat is informatie? Bron referentiele tekens (symbolen) berichten als rijtjes in code d c d d a b 11 10 11 11 00 01 111 011 110 001 (binair) 7 3 6 1 (octaal) ; 1110 1111 0001 (binair) E F 1 (hex, bytes) A B C D E F Informatieuitwisseling 26-11-2014 5
Vb. Braille Code Mens-mens communicatie 6-bit code, 2 6 = 64 symbolen mogelijk (sommige als control symbol) Ruimte voor cijfers, hoofdletters, leestekens, etc (1 of 2 bloks) Speciale codes voor wisk. notatie, etc Ook Braille muziekschrift Louis Braille (1809-1852) Code uit: 1829 Informatieuitwisseling 26-11-2014 6
Vb. Morse Code Samuel F.B. Morse (1791-1872) Code uit: 1835-37 Tbv telegrafie Begin communicatierevolutie Informatieuitwisseling 26-11-2014 7
Vb. ASCII (American Standard Code for Information Interchange) 8-bit code = 256 symbolen Informatieuitwisseling 26-11-2014 8
C.E. Shannon: A Mathematical Theory of Communication Bell System Technical Journal, 1948 The fundamental problem of communication is that of reproducing at one point either exactly or approximately a message selected at another point. Claude E. Shannon (1916-2001, vrmlg lid KNAW) UMich 1932-40, Princeton 1940-41, Bell 1941-56, MIT 1956-78 The significant aspect is that the actual message is one selected from a set of possible messages. The system must be designed to operate for each possible selection (Cf. Nyquist, Hartley ) A Mathematical Theory of Cryptography, 1946 A Mathematical Theory of Communication, 1948 The Mathematical Theory of Communication, 1949 Communication Theory of Secrecy Systems, 1949 Programming a Computer for Playing Chess, 1949 Informatieuitwisseling 26-11-2014 9
Shannon s begrip van informatie Information is what you don't know. If the receiver already had the information, you couldn't say that a communication had taken place. We're used to thinking about "information" as facts, data, evidence--but in information theory, information is uncertainty. You have to get a message that you don't know the content of. Information theory talks about the messages you could possibly get [ ] (C.A. Gimon) [ ] information must not be confused with meaning. [ ] two messages, one of which is heavily loaded with meaning and the other of which is pure nonsense, can be exactly equivalent, from the present viewpoint, as regards information." (D. Weaver) Informatieuitwisseling 26-11-2014 10
Shannon(-Weaver) Model (vgl. Layering) Informatieuitwisseling 26-11-2014 11
II. Codering bij de bron Vaste-lengte codering Vb. s 0 = 000 ; s 1 = 001 ; s 2 = 010 ; s 3 = 011 ; s 4 = 100 ; s 5 = 101 ; s 6 = 110 ; s 7 = 111 Met rijtjes van k bits lang: N symbolen (of berichten) onderscheiden vereist: k met 2 k 1 < N 2 k (dus k log 2 N) Vb. N = 5 k = 3 bits; N = 15 k = 4 bits. Variabele-lengte codering Vb. s 0 = 0 ; s 1 = 1 ; s 2 = 11 ; s 3 = 00 ; Probleem: 0011 s 3 s 4 s 0 s 1 s 2 Eis: codewoorden moeten uniquely decodable zijn (v.l.n.r.) Vb. s 0 = 0 ; s 1 = 10 ; s 2 = 110 ; s 3 = 1110 Informatieuitwisseling 26-11-2014 12
Prefix codes Klassiek voorbeeld variabele lengte codering: met binaire boom (zie voorbeeld). Eigenschap: geen codewoord is begin (`prefix ) van ander codewoord. Prefix codes, ook wel instantaneous codes genoemd. Kraft (1949): Prefix code met code lengtes l 0,, l N 1 bestaat dan en slechts dan als N 1 1 0 1 i=1 1 2 l i 0 1 0 1 Elk codewoord correspondeert met een blad in de binaire boom s 0 = 00 s 1 = 01 s 2 = 10 (ook met andere symbolen dan 0,1 mogelijk) 0 1 s 3 = 110 s 4 = 111 Informatieuitwisseling 26-11-2014 13
Waarom variabele lengte codes? Neem bijv 5 symbolen: s 0, s 1, s 2, s 3, s 4. Met vast lengte code: s 0 000; s 1 001; s 2 010; s 3 011; s 4 100 en x 101; x 110; x 111 (dus 3 bits/symbol) Stel nu frequenties: s 0 : 0,5; s 1 : 0,2 ; s 2 : 0,2 ; s 3 : 0,05 ; s 4 : 0,05. Kritiek Vgl alfabet gewone talen. Vgl. Morse code! a. Deel code ongebruikt: oplosbaar Gebruik code voor blokken van symbolen, bijv lengte N. 2 k 1 < 5 N 2 k, dus N k log 2 5, Gemiddeld: N log k 2 5 2,32 bits/symbol! b. Veel bits voor veel gebruikte symbolen (s 0, s 1 ): oplosbaar s 0 0; s 1 10; s 2 110; s 3 1110; s 4 1111 0,5 1 + 0,2 2 +0,2 3 + 0,05 4 + 0.05 4) = 1,90 bits/symb! Informatieuitwisseling 26-11-2014 14
Hoeveel bits aan informatie? Stel bron genereert symbolen volgens kansverdeling (zonder geheugen). Symbool met kans p = 1 2 : (1 uit 2) 1 bit aan informatie (nodig) Dito met kans p = 1 4 : (1 uit 4) 2 bits aan informatie (nodig) Met kans p =.. : (1 uit 1 p)? Onderscheiden met gemiddeld k bits Grofweg: 2 k 1 p, dus k log 2 1 p (met variatie) Informatiebegrip: Hoe meer berichten mogelijk, des te groter de onzekerheid bij de ontvanger. Zelf-informatie in elk symbool a dat wordt gegenereerd: I(a) = log 2 p = log 2 1 I(a b) = I(a) +I(b) p bits (Hartley, 1928) 1 log 2 = log 1 p q 2 + log 1 p 2 q Ook axiomatisch te verantwoorden (Shannon). Informatieuitwisseling 26-11-2014 15
Shannon (voor sources zonder geheugen) Bron genereert symbolen met waarschijnlijkheden: N 1 Bron S : s 0 p 0 ; s 1 p 1 ; ; s N 1 p N 1 ( 0 p i = 1) Kenmerk voor willekeurige uniquely decodable binaire code C? Stelling van Shannon (1948) Voor elke u.d. binaire code C geldt: gemiddeld aantal bits/symbol N 1 1 i=0 p i log 2 p i = H S. Er is een u.d. binaire code C met gemiddeld aantal bits L zodanig dat H S L H S + 1. H(S) heet de entropie van de bron. Vb. s 0 : 0,50 ; s 1 : 0,20 ; s 2 : 0,20 ; s 3 : 0,05 ; s 4 : 0,05 H S = 0,5 1 + 0,2 2,32 + 0,2 2,32 + 0,05 4,32 + 0,05 4,32 = 1,861 NB. Hadden een code met gem aantal bits/symbol 1,90. Close! Informatieuitwisseling 26-11-2014 16
Stelling van Shannon: Geillustreerd aan een variabele-lengte code voor het gewone (engelse) alfabet. Merk op: l log 2 1 p (Vb van best mogelijke prefix code dwz. met minimum gemiddeld aantal bits/symbool.) Informatieuitwisseling 26-11-2014 17
Interpretatie: grenzen voor beste source coding Shannon a: Voor gemiddeld aantal bits L geldt ALTIJD L H S. Shannon b: die ondergrens is ook willekeurig dicht te benaderen met geschikte codering. Volgens Shannon is er een u.d. code met L H S + 1. Codeer nu de symbolen in blokken van de vorm s i1 s in (met kans p i1 p in ). Hiermee krijgen we een gemiddelde code-lengte per symbool van H S = 1 n H Sn L 1 n ( H(Sn ) +1) = H S + 1 n Als gem. aantal bits/symbol van een code onder de bron-entropie zit, dan code niet `fout-vrij (niet u.d), meer dan 1 erboven redundant. Beperkingen: Symboolfrequenties moeten bekend (en constant) zijn. Hoe ziet de efficiente codes er uit? Praktisch genoeg? Informatieuitwisseling 26-11-2014 18
III. Datacompressie: verminder redundantie? Grove schattingen (vgl college over Multimedia): Tekst: 1 p 5 kb, 1000 p 5 mb Audio: 30 sec met 16 bits/sample en 44100 samples/sec over twee kanalen 5.3 mb. Uur audio: 635 mb. Video: 30 frames/sec, 8 mb/sec zwart-wit, 24 mb/sec color. Twee uur video: ongev 100 tot 200 gb. Reduceer het benodigd aantal bits om ( echte ) informatie te representeren Minder bits uit te wisselen: spaart transmissietijd, transmissiekosten, bandbreedte Minder geheugenruimte voor opslag, meer files op server 75% compressie: 1 4 van oorspronkelijke size Dicht bij de entropiegrens? Eronder? NB Nog altijd los van de inhoud of betekenis van de input! Informatieuitwisseling 26-11-2014 19
Typen Datacompressie (vgl Multimedia) source file compressor gecodeerde file gecodeerde file decompressor source file Lossless (codering exact omkeerbaar ) Behoudt alle informatie Benut redundantie Algemeen toepasbaar, essentieel bij tekst (Zip) Lossy (is niet exact omkeerbaar) Informatie kan deels verloren gaan Benut redundantie en perceptie van de data Vooral toegepast op beeld, video, audio: JPEG, MPEG (mp3, mp4), HDTV Informatieuitwisseling 26-11-2014 20
Datacompressie comprimeert niet altijd Elke methode van lossless datacompressie zal sommige files niet tot minder bits kunnen comprimeren. Stel wel. Neem vb van 1000-bit files. Aantal verschillende files van 1000 bits: 2 1000 Aantal verschillende files van hoogstens 999 bits: 1 + 2 + + 2 999 = 2 1000 1. Dus tenminste 2 files van 1000 bits zouden tot zelfde file van 999 bits gecomprimeerd worden. Tegenspraak! Lossy compressie haalt doorgaans hogere compressie percentages Lossless haalt 50-75%, lossy haalt 90% compressie Gecompenseerd door menselijke waarneming Mik op goede compressie in de praktijk Informatieuitwisseling 26-11-2014 21
Beste compressie van redundanties? Redundantie Een erg regelmatig ( voorspelbaar ) rijtje symbolen bevat veel semantische informatie; vb. 01100110011001100110 Een onvoorspelbaar rijtje symbolen bevat weinig semantische informatie; vb 01000001110110011010010 ; comprimeren? Minimum description length (MDL) Stel K maakt beste compressor voor willekeurige s; dus K(s) kleinste programma dat rijtje s uitprint (lossless). Kolmogorov: K(s) niet berekenbaar, dwz er is geen programma dat, gegeven s, de kleinste compressie van elke s berekent. Meeste rijtjes random en niet (erg) comprimeerbaar. In de praktijk wel Methoden die daar gebruik van maken (codecs) A.N. Kolmogorov (1903-1987) Informatieuitwisseling 26-11-2014 22
a. Lossless met prefix coding Binaire boom volgorde symbolen doet er niet toe minst frequente symbolen zitten diepst als n > 1, dan altijd (tenminste) twee bladen in onderste niveau die dezelfde ouder hebben Huffman (1952) Maak binaire boom bottom up Maak twee bladen voor de twee minst-frequente symbolen x en y Zo verder, met x en y vervangen door metasymbool xy (met de gesommeerde frequentie) Geeft optimale (compressie met) prefix code x y David A. Huffman (1925-1999) Informatieuitwisseling 26-11-2014 23
Huffman codering Vb s 0 : 0,5 ; s 1 : 0,2 ; s 2 : 0,2 ; s 3 : 0,05; s 4 : 0,05 s 0 = 1 ; s 1 = 00 ; s 2 = 011; s 3 = 0101 ; s 4 = 0100 Gem 1,90 bits/symbool Beste prefix code in bits/symb. Niet uniek Feit: Gem. aantal bits/symbool is bijna optimaal: H(S) L Huffman H S + 1 Met blocks van N symbols nog beter: H(S) L H S + 1 N JvL (1976): na sorteren, lineair. s 1 0,2 0,5 0,1 s 4 0,05 0,3 s 3 0,05 1,0 s 2 0,2 s 0 0,5 Informatieuitwisseling 26-11-2014 24
b. Runlength encoding (RLE) Vervang herhaling van patronen door tel-code ACCEDGGGGGGAAAAEEE ACCED@G5@A4@E3 Varianten, bv. alleen voor deelrijtjes 0-en ( zero runlength encoding ) Eenvoudig, lossless Alleen effectief als er veel herhalingen zijn BBWWWWWWWWWWWWWWBBBBBBBBBBBBBBBBBBBBBBBBBBBB Vb in beelddata, bitmaps Impliciet, in combinatie met resp. ingebed in andere compressiemethoden Informatieuitwisseling 26-11-2014 25
c. Lempel-Ziv-Welch (LZW) compressie (1977-1984) Gebruikt tabel met (veel-)voorkomende tekstpatronen, en codeert mbv de lijnnummer uit de tabel (woordenboek). Stel alfabet : de letters a en b. In de praktijk bijv ASCII code (256 symbolen). De letters van het alfabet gaan eerst in de tabel, code numbers beginnen bij 0. Tabel begint als: code key 0 a 1 b Abraham Lempel (1936) Jacob Ziv (1931) Terry A. Welch (19??-1988) Informatieuitwisseling 26-11-2014 26
code key 0 a 1 b Brontext = abababbabaabbabbaabba Scan de brontekst van links naar rechts Vanaf waar je bent: bepaal langste stukje text p dat al in de tabel voorkomt. Codeer dat stukje door getal: Code-p Is x het volgende symbool na p, voeg dan px in als volgende regel in de tabel (beter: vervang px door Code-p x tijdens coderen) Ga verder bij symbool x. Informatieuitwisseling 26-11-2014 27
code key 0 a 1 b 2 ab Bron = abababbabaabbabbaabba Comp = (wordt de gecomprimeerde text) p = a (huidige key) Code-p = 0 (huidige code) x = b Codeer a door 0 en voeg px = ab in de tabel. Comp := 0 Informatieuitwisseling 26-11-2014 28
code key 0 a 1 b 2 ab 3 ba Bron = abababbabaabbabbaabba Comp = 0 p = b Code-p = 1 x = a Codeer b door 1 en voeg px = ba in de tabel. Comp := 01 Informatieuitwisseling 26-11-2014 29
code key 0 a 1 b 2 ab 3 ba 4 aba Bron = abababbabaabbabbaabba Comp = 01 p = ab Code-p = 2 x = b Codeer ab door 2 en voeg px = aba in. Comp := 012 Informatieuitwisseling 26-11-2014 30
code key 0 a 1 b 2 ab 3 ba 4 aba 5 abb Bron = abababbabaabbabbaabba Comp = 012 p = ab Code-p = 2 x = b Codeer ab door 2 en voeg px = abb in. Comp := 0122 Informatieuitwisseling 26-11-2014 31
code key 0 a 1 b 2 ab 3 ba 4 aba 5 abb 6 bab Bron = abababbabaabbabbaabba Comp = 0122 p = ba Code-p = 3 x = b Codeer ba door 3 en voeg px = bab in. Comp := 01223 Informatieuitwisseling 26-11-2014 32
code key 0 a 1 b 2 ab 3 ba 4 aba 5 abb 6 bab 7 baa Bron = abababbabaabbabbaabba Comp = 01223 p = ba Code-p = 3 x = a Codeer ba door 3 en voeg px = baa in. Comp := 012233 Informatieuitwisseling 26-11-2014 33
code key 0 a 1 b 2 ab 3 ba 4 aba 5 abb 6 bab 7 baa 8 abba Bron = abababbabaabbabbaabba Comp = 012233 p = abb Code-p = 5 x = a Codeer abb door 5 en voeg px = abba in. Comp := 0122335 Informatieuitwisseling 26-11-2014 34
code key 0 a 1 b 2 ab 3 ba 4 aba 5 abb 6 bab 7 baa 8 abba 9 abbaa Bron = abababbabaabbabbaabba Comp = 0122335 p = abba Code-p = 8 x = a Codeer abb door 5 en voeg px = abbaa in. Comp := 01223358 Informatieuitwisseling 26-11-2014 35
code key 0 a 1 b 2 ab 3 ba 4 aba 5 abb 6 bab 7 baa 8 abba 9 abbaa Bron = abababbabaabbabbaabba Comp = 01223358 p = abba Code-p = 8 x = - Codeer abb door 5 en voeg niets in. Comp := 012233588 Informatieuitwisseling 26-11-2014 36
LZW compressie, en decompressie? Alleen: code key 0 a 1 b Stuur: (codetabel +) 012233588 (=Comp) Feit: Tijdens het decoderen (van links naar rechts) kan men gelijk de complete codetabel mee reconstrueren! Decompressie loopt steeds een beetje voor zodat de tabel-entries precies op tijd zijn te hermaken. Gecomprimeerde tekst bevat impliciet alle data die benodigd is voor decompressie Informatieuitwisseling 26-11-2014 37
Meer over data compressie LZW (vgl. college Multimedia) Adaptive dictionary method. Compressie 60 %. Compressie verwacht lineair, decoderen lineair. Basis voor bijv. GIF (Graphics Interchange Format) Hybride codering Bv. LZW met Huffman als backend (bv 7-Zip) Universal coding: schat frequenties in een aparte pass Vele andere codecs ( lossless en lossy ) Arithmetic coding, Burrows-Wheeler, qr code, etc WMV, WMA, JPEG, MPEG, wavelets, etc JPEG = Joint photographic expert group MPEG = Motion picture expert group Algoritmen ipv tabellen Informatieuitwisseling 26-11-2014 38
IV. Shannon s Uitspraken over Communicatie Transmitter encryptie source source channel netwerk bron coder coder Bericht decryptie... Receiver netwerk channel source destination decoder decoder ontvanger noise ruis Bericht Informatieuitwisseling 26-11-2014 39
a. Channel zonder ruis (vgl entropie) Shannon s source coding theorem (voor ruisvrije communicatie): Stel de bron heeft entropie H (bits/symbol) en de lijn heeft capaciteit C (bits/sec). Dan zijn de signalen van de bron te coderen zodanig dat gemiddeld C ε symbolen/sec (foutvrij) H gecommuniceerd worden (ε willekeurig klein). Een gemiddelde groter dan C H is niet mogelijk. source, bron source coder (channel coder) (channel decoder) source decoder destination ontvanger Informatieuitwisseling 26-11-2014 40
b. Channel coding met ruis Ruis: ontvangen signaal is niet altijd gelijk aan het verzonden signaal 1001 0101 1010 (channel) 1001 0101 0010 Mogelijkheid va bit flips (extra) onzekerheid bij ontvanger Error correction Stuur bytes herhaald: 0 als 000, 1 als 111, etc Error-correcting codes: check bits, CRC checks, etc Veelgebruikt: block codes (met ruime afstand tussen blocks) source, source channel (channel) bron coder coder (channel) channel source destination noise ruis decoder decoder ontvanger Informatieuitwisseling 26-11-2014 41
Channel coding met ruis Shannon s noisy coding theorem (communicatie met ruis): Een ruisig channel heeft een karakteristieke capaciteit, dwz. maximum informatie doorgeef snelheid C zodanig dat, als de bron R = r H bits/sec verstuurt (H de entropie), dan: Is R < C, dan bestaat er een block code waarmee oorspronkelijke symbolen correct zijn te decoderen met kans willeurig dicht bij 1 (met inbegrip van ruiseffect), Is R > C, dan is die kans bij elke block code zo goed als 0. source, source channel (channel) bron coder coder (channel) channel source destination noise ruis decoder decoder ontvanger Informatieuitwisseling 26-11-2014 42
Nabeschouwing Shannon-Weaver model: algemeen, overzichtelijk, zeer invloedrijk in verdere modelvorming en onderzoek Instrumenteel model, abstraheert van soort medium, goed voor kwantitatieve analyse van (onderdelen van) communicatie Geschikt voor modellering (technische) communicatie met enkele zender en ontvanger. Model houdt geen rekening met effect van tussentijdse feedback. (Communicatie is niet 1-way.) Model houdt geen rekening met context, semantische en gedragsaspecten (vgl Weaver s indeling) Informatieuitwisseling 26-11-2014 43
Informatieuitwisseling: Overige niveaus? Warren Weaver (1894-1978) In: Shannon/Weaver 1949, p 4. Level A. How accurately can the symbols of communication be transmitted? (The technical problem.)? Level B. How precisely do the transmitted symbols convey the desired meaning? (The semantic problem.)? Level C. How effectively does the received meaning affect conduct in the desired way? (The effectiveness problem.) Informatieuitwisseling 26-11-2014 44
V. Conclusies Informatieuitwisseling ihb met computers Gartner Inc (2011): Information is the oil of the 21st century Model voor effectiviteit van technische communicatie (de pipelines ) Informatie reductie in onzekerheid Entropie van de bron geeft grens op benodigd gemiddeld aantal bits/teken. Informatie als kwantificeerbaar goed Informatiebehoud bij compressie, methode? Goede coderingen, afhankelijk van toepassing Uitwisseling kan zonder fouten mits binnen zekere kwantitatieve grenzen Shannon s informatietheorie Informatieuitwisseling 26-11-2014 45
Informatieuitwisseling 26-11-2014 46
DISCLAIMER These slides are for internal use only. They are not meant for distribution or posting in public media outside the realm of the course. All materials are intended for educational use in IUW only. Illustrations, tables and other possibly copyrighted materials should be cited by their original sources. Any violations of copyright will be removed once they become known to us. Informatieuitwisseling 26-11-2014 47