Quoto

Learn / Library / Probability

Bits saved on a log

ProbabilityMedium

A logger stores the state of the spread, which has values with probabilities , , , , and . A fixed-length binary code uses the fewest whole bits that give every value its own word. How many bits in total does an optimal prefix code save over that fixed-length code on states, in expectation? Give a whole number.

Checking an answer needs JavaScript. The hint and the solution open without it.

A whole number, a decimal, a fraction like 3/8 or a percent.

Hint

Find the entropy, since a code can reach it when probabilities are powers of .

Solution
  1. All probabilities are powers of , so an optimal prefix code has word lengths , , , , , and averages the entropy: bits.
  2. Telling values apart takes bits, because is too few and is enough.
  3. The saving per state is , so the total is .

Answer: