Content deleted Content added
Rescuing 1 sources and tagging 0 as dead. #IABot (v2.0beta15) |
Adding short description: "Lossless data compression algorithm" |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 1:
{{Short description|Lossless data compression algorithm}}
'''Dynamic Markov compression''' ('''DMC''') is a lossless [[data compression]] [[algorithm]] developed by [[Gordon Cormack]] and [[Nigel Horspool]].<ref>Gordon Cormack and Nigel Horspool, "Data Compression using Dynamic Markov Modelling", Computer Journal 30:6 (December 1987)</ref> It uses predictive [[arithmetic coding]] similar to [[prediction by partial matching]] (PPM), except that the input is predicted one bit at a time (rather than one byte at a time). DMC has a good compression ratio and moderate speed, similar to PPM, but requires somewhat more memory and is not widely implemented. Some recent implementations include the experimental compression programs [http://cs.fit.edu/~mmahoney/compression/text.html#1781 hook] by Nania Francesco Antonio, [https://web.archive.org/web/20091026235047/http://de.geocities.com/ocamyd/ ocamyd] by Frank Schwellinger, and as a submodel in [[PAQ|paq8l]] by Matt Mahoney. These are based on the [https://web.archive.org/web/20070630111546/http://plg.uwaterloo.ca/~ftp/dmc/dmc.c 1993 implementation] in C by Gordon Cormack.
Line 7 ⟶ 8:
=== Arithmetic coding ===
A bitwise arithmetic coder such as DMC has two components, a predictor and an arithmetic coder. The predictor accepts an ''n''-bit input string ''x'' = ''x''<sub>1</sub>''x''<sub>2</sub>...''x''<sub>''n''</sub> and assigns it a probability ''p''(''x''), expressed as a product of a series of predictions, ''p''(''x''<sub>1</sub>)''p''(''x''<sub>2</sub>'''|'''''x''<sub>1</sub>)''p''(''x''<sub>3</sub>'''|'''''x''<sub>1</sub>''x''<sub>2</sub>) ... ''p''(''x''<sub>''n''</sub>'''|''' ''x''<sub>1</sub>''x''<sub>2</sub>...''x''<sub>''n''–1</sub>). The arithmetic coder maintains two high precision binary numbers, ''p''<sub>low</sub> and ''p''<sub>high</sub>, representing the possible range for the total probability that the model would assign to all strings lexicographically less than ''x'', given the bits of ''x'' seen so far. The compressed code for ''x'' is ''p''<sub>''x''</sub>, the shortest bit string representing a number between ''p''<sub>low</sub> and ''p''<sub>high</sub>. It is always possible to find a number in this range no more than one bit longer than the [[Claude Shannon|Shannon]] limit, log<sub>2</sub> 1 '''/''' ''p''(''x''). One such number can be obtained from ''p''<sub>high</sub> by dropping all of the trailing bits after the first bit that differs from ''p''<sub>low</sub>.
Compression proceeds as follows. The initial range is set to ''p''<sub>low</sub> = 0, ''p''<sub>high</sub> = 1. For each bit, the predictor estimates ''p''<sub>0</sub> = ''p''(''x''<sub>''i''</sub> = 0'''|'''''x''<sub>1</sub>''x''<sub>2</sub>...''x''<sub>''i''–1</sub>) and ''p''<sub>1</sub> = 1 − ''p''<sub>0</sub>, the probability of a 0 or 1, respectively. The arithmetic coder then divides the current range, (''p''<sub>low</sub>, ''p''<sub>high</sub>) into two parts in proportion to ''p''<sub>0</sub> and ''p''<sub>1</sub>. Then the subrange corresponding to the next bit ''x''<sub>''i''</sub> becomes the new range.
For decompression, the predictor makes an identical series of predictions, given the bits decompressed so far. The arithmetic coder makes an identical series of range splits, then selects the range containing ''p''<sub>''x''</sub> and outputs the bit ''x''<sub>''i''</sub> corresponding to that subrange.
In practice, it is not necessary to keep ''p''<sub>low</sub> and ''p''<sub>high</sub> in memory to high precision. As the range narrows
=== DMC model ===
The DMC predictor is a table which maps (bitwise) contexts to a pair of counts, ''n''<sub>0</sub> and ''n''<sub>1</sub>, representing the number of zeros and ones previously observed in this context. Thus, it predicts that the next bit will be a 0 with probability ''p''<sub>0</sub> = ''n''<sub>0</sub> '''/''' ''n'' = ''n''<sub>0</sub> '''/''' (''n''<sub>0</sub> + ''n''<sub>1</sub>) and 1 with probability ''p''<sub>1</sub> = 1 − ''p''<sub>0</sub> = ''n''<sub>1</sub> '''/''' ''n''. In addition, each table entry has a pair of pointers to the contexts obtained by appending either a 0 or a 1 to the right of the current context (and possibly dropping bits on the left). Thus, it is never necessary to look up the current context in the table; it is sufficient to maintain a pointer to the current context and follow the links.
In the original DMC implementation, the initial table is the set of all contexts of length 8 to 15 bits that begin on a byte boundary. The initial state is any of the 8 bit contexts. The counts are floating point numbers initialized to a small nonzero constant such as 0.2. The counts are not initialized to zero in order to allow values to be coded even if they have not been seen before in the current context.
Line 93 ⟶ 94:
[[Category:Lossless compression algorithms]]
[[Category:Markov models]]
[[Category:Data compression]]
|