# Huffman encoding

1. Jan 11, 2007

### ppp

My source is exp(-x) and I would like to compute the probability vector so as to use in huffman function for (N=4 bits).

[code,len]=Huffman(p)

May someone help me ???
I don't know hot can I find the probability vercto.

Thanks

2. Jan 11, 2007

### Jheriko

Lets say that you have n different symbols making up m symbols worth of sample data. The probability for each symbol is the number of occurances of n divided by m. The probability vector is just a vector of all of these probabilities (one for each symbol).

For 4-bit symbols you have 2^4 = 16 symbols. Suppose that you have the following trivial example:

0001 0010 0011 1000 1001 0011 0001

then the probability vector would be (column vector)

2/7
1/7
2/7
0
0
0
0
1/7
1/7
0
0
0
0
0
0

Hope this helps.