Decode binary code by arithmetic decoding
decodes the binary arithmetic code in
dseq = arithdeco(
code to recover the corresponding
len symbols. The input
the statistics of the source by listing the number of times each symbol of the source
alphabet occurs in a test data set.
code must be an output of the
Decode Sequence Using Arithmetic Code
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];
Generate a random sequence of length 1000.
len = 1000; seq = randsrc(1,len,[1 2; .99 .01]);
Encode the random sequence. Then, decode the encoded sequence.
code = arithenco(seq,counts); dseq = arithdeco(code,counts,length(seq));
Verify that the decoded sequence matches the original random sequence.
ans = logical 1
code — Binary arithmetic code
nonnegative binary row vector
Binary arithmetic code, specified as a nonnegative binary row vector. This value
must be a binary arithmetic code produced by the
counts — Statistics of symbols
positive numeric vector
Statistics of symbols, specified as a positive numeric vector. This input specifies the number of times each symbol of the source alphabet occurs in a test data set.
len — Length of sequence
Length of the sequence to decode, specified as a positive scalar.
arithdeco function uses the algorithm described in  .
 Sayood, Khalid. Introduction to Data Compression. 2nd ed. San Francisco: Morgan Kaufmann Publishers, 2000.