tailieunhanh - Less-Numerical Algorithms part 6
We saw in the previous section that a perfect (entropy-bounded) coding scheme would use Li = − log2 pi bits to encode character i (in the range 1 ≤ i ≤ Nch ), if pi is its probability of occurrence. | 910 Chapter 20. Less-Numerical Algorithms Coding We saw in the previous section that a perfect entropy-bounded coding scheme would use Li - log2 pi bits to encode character i in the range 1 i Nch if pi is its probability of occurrence. Huffman coding gives a way of rounding the Li s to close integer values and constructing a code with those lengths. Arithmetic coding 1 which we now discuss actually does manage to encode characters using noninteger numbers of bits It also provides a convenient way to output the result not as a stream of bits but as a stream of symbols in any desired radix. This latter property is particularly useful if you want . to convert data from bytes radix 256 to printable ASCII characters radix 94 or to case-independent alphanumeric sequences containing only A-Z and 0-9 radix 36 . In arithmetic coding an input message of any length is represented as a real number R in the range 0 R 1. The longer the message the more precision required of R. This is best illustrated by an example so let us return to the fictitious language Vowellish of the previous section. Recall that Vowellish has a 5 character alphabet A E I O U with occurrence probabilities and respectively. Figure shows how a message beginning IOU is encoded The interval 0 1 is divided into segments corresponding to the 5 alphabetical characters the length of a segment is the corresponding pi. We see that the first message character I narrows the range of R to R . This interval is now subdivided into five subintervals again with lengths proportional to the pi s. The second message character O narrows the range of R to R . The U character further narrows the range to R . Any value of R in this range can be sent as encoding IOU . In particular the binary fraction .011000001 is in this range so IOU can be sent in 9 bits. Huffman coding took 10 bits for this example see . Of course there is the problem
đang nạp các trang xem trước