早教吧 育儿知识 作业答案 考试题库 百科 知识分享

哈夫曼编码函数[dict,avglen]=huffmandict(symbols,p,N),symbols,p,N,variance这几个代表什么意思啊?

题目详情
哈夫曼编码函数[dict,avglen]=huffmandict(symbols,p,N),symbols,p,N,variance这几个代表什么意思啊?
▼优质解答
答案和解析
HUFFMANDICT Code dictionary generator for Huffman coder.
DICT = HUFFMANDICT(SYM,PROB) generates a binary Huffman code
dictionary using the maximum variance algorithm for the distinct
symbols given by the SYM vector.The symbols can be represented as a
numeric vector or single-dimensional alphanumeric cell array.The
second input,PROB,represents the probability of occurrence for each
of these symbols.SYM and PROB must be of same length.
DICT = HUFFMANDICT(SYM,PROB,N) generates an N-ary Huffman code
dictionary using the maximum variance algorithm.N is an integer
between 2 and 10 (inclusive) that must not exceed the number of
source symbols whose probabilities appear in PROB.
DICT = HUFFMANDICT(SYM,PROB,N,VARIANCE) generates an N-ary Huffman
code with the specified variance.The possible values for VARIANCE are
'min' and 'max'.
[DICT,AVGLEN] = HUFFMANDICT(...) returns the average codeword length
of the Huffman code.
For example:
symbols = [1:5] % Alphabet vector
prob = [.3 .3 .2 .1 .1] % Symbol probability vector
[dict,avglen] = huffmandict(symbols,prob)
% Pretty print the dictionary.
temp = dict;
for i = 1:length(temp)
temp{i,2} = num2str(temp{i,2});
end
temp
See also huffmanenco,huffmandeco.
Reference page in Help browser
doc huffmandict