code = arithenco(seq,counts)
generates the binary arithmetic code corresponding to the sequence of symbols specified in
seq. The input counts specifies the statistics
of the source by listing the number of times each symbol of the source alphabet occurs in a
test data set.

Using a source with a two-symbol alphabet, produce a test data set in which 99% of the symbols are 1s. Encode 1000 symbols from this source to produce a code vector with less than 1000 elements. The actual number of elements in the encoded sequence varies depending on the particular random sequence.

Specify for symbol 1 from the source alphabet to occur 99 times in the test data set.

counts = [99 1]

counts = 1×2
99 1

Generate a random sequence of length 1000.

len = 1000;
seq = randsrc(1,len,[1 2; .99 .01]);

Encode the random sequence and display the encoded length.

seq — Sequence of symbols positive numeric row vector

Sequence of symbols, specified as a positive numeric row vector. This input
specifies the random sequence for the function to encode.

Data Types: double

counts — Statistics of symbols positive numeric row vector

Statistics of symbols, specified as a positive numeric row vector. This input
specifies the number of times each symbol of the source alphabet occurs in a test data
set.

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.