Compute Probability Vector for Huffman Function (N=4bits)

  • Thread starter ppp
  • Start date
In summary, to use the Huffman function for 4-bit symbols, you will need to compute a probability vector which represents the probability of each symbol occurring in the sample data. This can be done by dividing the number of occurrences of each symbol by the total number of symbols. For example, if you have 16 symbols and the sample data is 0001, 0010, 0011, 1000, 1001, 0011, 0001, then the corresponding probability vector would be (2/7, 1/7, 2/7, 0, 0, 0, 0, 1/7, 1/7, 0, 0, 0
  • #1
ppp
1
0
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
 
Technology news on Phys.org
  • #2
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.
 
  • #3
for your question. To compute the probability vector for a Huffman function with N=4 bits, you can use the following steps:

1. Determine the range of values for x: Since your source is exp(-x), the range of values for x would be from 0 to infinity.

2. Divide the range of values into 2^4 (N=4 bits) equal intervals: In this case, you would divide the range into 16 equal intervals, with each interval representing a different bit pattern.

3. Calculate the probability for each interval: To find the probability for each interval, you can use the following formula: P(x) = exp(-x) / ∫exp(-x)dx (where ∫exp(-x)dx represents the integral of exp(-x) over the entire range of values for x).

4. Create the probability vector: Once you have calculated the probabilities for each interval, you can create a probability vector with 16 elements, where each element represents the probability for that particular interval.

5. Use the probability vector in the Huffman function: Finally, you can use the probability vector you created as input for the Huffman function (code,len]=Huffman(p)) to generate the optimal code for each interval.

I hope this helps. Good luck with your computation!
 

1. What is the purpose of computing a probability vector for Huffman function?

The purpose of computing a probability vector for Huffman function is to determine the probability of occurrence for each symbol in a given set of data. This information is then used to construct an optimal Huffman code, which can efficiently compress the data for storage or transmission.

2. How is the probability vector calculated for Huffman function?

The probability vector is calculated by dividing the frequency of each symbol in the data set by the total number of symbols. For example, if there are 100 symbols in the data and the symbol "A" appears 20 times, then the probability of "A" occurring is 20/100 or 0.2.

3. What is the significance of using N=4bits in computing the probability vector for Huffman function?

N=4bits indicates that the data set contains symbols that can be represented by 4 bits of binary code. This means that there are 16 possible symbols in the data set, and the probability vector will have 16 entries, each representing the probability of occurrence for a specific symbol.

4. Can the Huffman code be efficiently constructed without computing the probability vector?

No, the Huffman code relies on the probability vector to determine the optimal coding scheme for the data set. Without the probability vector, it would not be possible to efficiently compress the data using Huffman coding.

5. How does the size of the data set affect the computation of the probability vector for Huffman function?

The size of the data set does not affect the computation of the probability vector itself, as it is based on the frequency of each symbol and not the total number of symbols. However, a larger data set may require more memory and processing power to compute the probability vector and construct the Huffman code.

Similar threads

Replies
9
Views
943
  • Programming and Computer Science
2
Replies
63
Views
3K
  • Programming and Computer Science
Replies
15
Views
2K
  • Programming and Computer Science
2
Replies
36
Views
3K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
19
Views
2K
  • Programming and Computer Science
2
Replies
53
Views
3K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
15
Views
2K
Back
Top