Products & Services Solutions Academia Support User Community Company

Learn more about Communications Toolbox   

huffmandict - Generate Huffman code dictionary for source with known probability model

Syntax

[dict,avglen] = huffmandict(symbols,p)
[dict,avglen] = huffmandict(symbols,p,N)
[dict,avglen] = huffmandict(symbols,p,N,variance)

Description

For All Syntaxes

The huffmandict function generates a Huffman code dictionary corresponding to a source with a known probability model. The required inputs are

The outputs of huffmandict are

For Specific Syntaxes

[dict,avglen] = huffmandict(symbols,p) generates a binary Huffman code dictionary using the maximum variance algorithm.

[dict,avglen] = huffmandict(symbols,p,N) generates an N-ary Huffman code dictionary using the maximum variance algorithm. N is an integer between 2 and 10 that must not exceed the number of source symbols whose probabilities appear in the vector p.

[dict,avglen] = huffmandict(symbols,p,N,variance) generates an N-ary Huffman code dictionary with the minimum variance if variance is 'min' and the maximum variance if variance is 'max'. N is an integer between 2 and 10 that must not exceed the length of the vector p.

Examples

symbols = [1:5];
p = [.3 .3 .2 .1 .1];
[dict,avglen] = huffmandict(symbols,p)
samplecode = dict{5,2} % Codeword for fifth signal value

The output is below, where the first column of dict lists the values in symbols and the second column lists the corresponding codewords.

dict = 

    [1]    [1x2 double]
    [2]    [1x2 double]
    [3]    [1x2 double]
    [4]    [1x3 double]
    [5]    [1x3 double]


avglen =

    2.2000


samplecode =

     1     1     0

See Also

huffmanenco, huffmandeco, Huffman Coding

References

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

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS