Main Content

arithenco

Encode sequence of symbols by arithmetic encoding

Description

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.

example

Examples

collapse all

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.

code = arithenco(seq,counts);
s = size(code)
s = 1×2

     1    57

Input Arguments

collapse all

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

Data Types: double

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.

Data Types: double

Output Arguments

collapse all

Generated binary arithmetic code corresponding to the sequence of source symbols, returned as a nonnegative binary row vector.

Algorithms

The arithenco function uses the algorithm described in [1].

References

[1] Sayood, Khalid. Introduction to Data Compression. 2nd ed. San Francisco: Morgan Kaufmann Publishers, 2000.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a

expand all

See Also

Functions