Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compressibility Example

From my algorithms textbook:

The annual county horse race is bringing in three thoroughbreds who have never competed against one another. Excited, you study their past 200 races and summarize these as probability distributions over four outcomes: first (“first place”), second, third, and other.

                       Outcome     Aurora   Whirlwind    Phantasm
                        first        0.15      0.30          0.20

                        second       0.10      0.05          0.30

                        third        0.70      0.25          0.30

                        other        0.05      0.40          0.20

Which horse is the most predictable? One quantitative approach to this question is to look at compressibility. Write down the history of each horse as a string of 200 values (first, second, third, other). The total number of bits needed to encode these track-record strings can then be computed using Huffman’s algorithm. This works out to 290 bits for Aurora, 380 for Whirlwind, and 420 for Phantasm (check it!). Aurora has the shortest encoding and is therefore in a strong sense the most predictable.

How did they get 420 for Phantasm? I keep getting 400 bytes, as so:

Combine first, other = 0.4, combine second, third = 0.6. End up with 2 bits encoding each position.

Is there something I've misunderstood about the Huffman encoding algorithm?

Textbook available here: http://www.cs.berkeley.edu/~vazirani/algorithms.html (page 156).

like image 856
Dijkstra Avatar asked Jun 10 '10 13:06

Dijkstra


People also ask

What is example of compressibility from our daily life?

-By compression of air, we can blow things like a balloon and at the same time collapse them.

What do you mean by compressibility explain with example?

: capability of compression : the ability of something (such as a fluid) to be reduced in volume or size under pressure. When that water expands, it turns into a gas. The gas forms bubbles and those bubbles dilute the compressibility of the brake fluid.

What is compressibility of an object?

Compressibility is a measure of the change in volume resulting from the external pressure applied to the surface of an object. The fractional volume change of an object is the ratio of the change in volume ΔV to the initial volume V.

What is compressibility used for?

Compressibility is an important factor in aerodynamics. At low speeds, the compressibility of air is not significant in relation to aircraft design, but as the airflow nears and exceeds the speed of sound, a host of new aerodynamic effects become important in the design of aircraft.


1 Answers

I think you're right: Phantasm's 200 outcomes can be represented using 400 bits (not bytes). 290 for Aurora and 380 for Whirlwind are correct.

The correct Huffman code is generated in the following manner:

  1. Combine the two least probable outcomes: 0.2 and 0.2. Get 0.4.
  2. Combine the next two least probable outcomes: 0.3 and 0.3. Get 0.6.
  3. Combine 0.4 and 0.6. Get 1.0.

You would get 420 bits if you did this instead:

  1. Combine the two least probable outcomes: 0.2 and 0.2. Get 0.4.
  2. Combine 0.4 and 0.3. (Wrong!) Get 0.7.
  3. Combine 0.7 and 0.3. Get 1.0
like image 73
Steve Tjoa Avatar answered Oct 21 '22 22:10

Steve Tjoa