home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / compress / 2774 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  5.3 KB

  1. Path: sparky!uunet!decwrl!concert!duke!srt
  2. From: srt@duke.cs.duke.edu (Stephen R. Tate)
  3. Newsgroups: comp.compression
  4. Subject: Re: entropy
  5. Message-ID: <711820693@pike.cs.duke.edu>
  6. Date: 22 Jul 92 15:58:14 GMT
  7. References: <1992Jul22.144104.27576@usenet.ins.cwru.edu>
  8. Organization: Duke University Computer Science Dept.; Durham, N.C.
  9. Lines: 99
  10.  
  11.  
  12. In article <1992Jul22.144104.27576@usenet.ins.cwru.edu> daf10@po.CWRU.Edu (David A. Ferrance) writes:
  13. >Right now I compute the entropy of a file by summing the probability of
  14. >each character ocurring times the log (base2) of the reciprocal of that
  15. >probability.  This gives me the theoretical minimum number of bits
  16. >needed to represent each character, on average (from what I understand).
  17. >What I would like to know is, does this number only work for first order
  18. >(1-ary?) compression techniques or does it serve also as a limit for
  19. >more complex techniques?  If it does not serve for the more complex
  20. >techniques (and I suspect it doesn't), is there any way to determine
  21. >entropies for different orders?
  22.  
  23. Warning:  another one of my long-winded explanations of information
  24. theory follows!
  25.  
  26. What you have calculated is the order-0 entropy of the sequence.
  27. (Incidentally, there is a lot of disagreement about the terminology
  28. here --- some people would call it the order-1 entropy.)  This is
  29. the minimum average code length if every character is encoded
  30. independently of the other characters.  Needless to say, this only
  31. applies to the most basic of compression methods.
  32.  
  33. If you're not scared of a little math, the following will explain
  34. a little more about entropy --- it's really not all that hard, but
  35. you need to know the basics of probability, and you might have to
  36. think about it for a while to let it really sink in.
  37.  
  38. Just as you calculated the entropy from the probabilities of
  39. individual characters, you can calculated it based on larger groups of
  40. characters.  In particular, let P_m(x_1,x_2,...,x_m) denote the
  41. probability of seeing the sequence of m characters x_1,x_2,...,x_m
  42. (pairs or triples of characters for example.)  Now you can calculate
  43. the expected value of the log (base 2) of the reciprocal of these
  44. probabilities over all m-tuples, divide by m, and you get the
  45. per-character entropy of the sequence of m-ary subsequences.  This is
  46. the minimum average code length possible per character if each m-tuple
  47. is coded independently.  Clearly, (well, think about it) the entropy
  48. never increases as m increases (in other words, you can always do
  49. better -- or at least no worse -- by encoding bigger and bigger chunks
  50. at a time).  Now the *entropy* (this is the true entropy) of a data
  51. source is:
  52.  
  53.       lim_{m->infinity} 1/m * E[ log(1/P_m(X_1,X_2,...,X_m)) ].
  54.  
  55. This is where there is some math you might want to think about.  The
  56. E[] stands for expected value, and here X_1,... are random variables.
  57. In other words, you just take the limit as m goes to infinity of the 
  58. per-character entropy that I described above.
  59.  
  60. This limit always exists if the data source is what is called "stationary"
  61. and "ergodic" --- I won't define these terms, but they're very common
  62. assumptions made in information theory.
  63.  
  64. This true entropy is the absolute minimum average code length that
  65. can be obtained (assuming a stationary ergodic source, of course!)
  66. for *any* coding/compression technique, regardless of how complicated
  67. it is.  Computing the true entropy is impossible from a finite
  68. sequence generated by the source, but it can be estimated by looking
  69. at reasonably sized m-tuples (for long samples of English text, you
  70. should be able to calculate up to m=8 or more).
  71.  
  72. There are many other ways of calculating entropy --- the best is
  73. possible if you know exactly what the source model is (i.e., the
  74. Markov chain describing the data source).  Then you can calculate the
  75. exact entropy --- you don't need to estimate.  Needless to say, it is
  76. rather rare that you know the source model.
  77.  
  78. To throw one more monkey-wrench in to things, let me add that the
  79. entropy lower bound is tight only if you assume that both encoder and
  80. decoder know the source model/encoding method.  In most cases this is
  81. not the case --- most compressors learn the source model as they
  82. encounter the input, and cannot reach the entropy lower bound.  In
  83. this case, you need to look at what is called the "stochastic
  84. complexity" of the sequence.  In particular, if you want a universal
  85. compressor (i.e., one that works for any stationary ergodic source),
  86. the best you can ever do in bits/character is
  87.  
  88.             H + 1/2 * k * log(n)/n,
  89.  
  90. where H is the entropy of the source, k is a constant that depends on
  91. how many states are in the source, and n is the number of characters
  92. in the sequence.  There are some source models that can beat this, but
  93. it's really not even worth discussing --- the set of models that can
  94. beat this lower bound has measure zero, so let's just pretend they
  95. don't exist.  In the limit (as you look at longer and longer strings)
  96. this approaches the entropy, but for finite length strings you can
  97. never quite reach the entropy.
  98.  
  99. That's about it for this weeks installment of Dr. Tate's "information
  100. theory on Usenet"...  :-)  Next week's class will be held on the beach
  101. with the topic being "information content of the human mind after the
  102. consumption of alcoholic beverages"....  Hope to see you there!
  103.  
  104.  
  105. -- 
  106. Steve Tate                         srt@duke.cs.duke.edu
  107. Dept. of Computer Science
  108. Duke University
  109. Durham, NC  27706
  110.