Encode sequence of symbols using arithmetic coding

`code = arithenco(seq,counts) `

`code = arithenco(seq,counts) `

generates
the binary arithmetic code corresponding to the sequence of symbols
specified in the vector `seq`

. The vector `counts`

represents
the source's statistics by listing the number of times each symbol
of the source's alphabet occurs in a test data set.

This example illustrates the compression that arithmetic coding
can accomplish in some situations. A source has a two-symbol alphabet
and produces a test data set in which 99% of the symbols are 1s. Encoding
1000 symbols from this source produces a code vector having many fewer
than 1000 elements. The actual number of elements in `code`

varies,
depending on the particular random sequence contained in `seq`

.

counts = [99 1]; % A one occurs 99% of the time. len = 1000; seq = randsrc(1,len,[1 2; .99 .01]); % Random sequence code = arithenco(seq,counts); s = size(code) % length of code is only 8.3% of length of seq.

The output is

s = 1 83

[1] Sayood, Khalid, *Introduction
to Data Compression,* San Francisco, Morgan Kaufmann, 2000.

Was this topic helpful?