Learn / Library / Probability
Bits saved on a log
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.
Hint
Find the entropy, since a code can reach it when probabilities are powers of .
Solution
- All probabilities are powers of , so an optimal prefix code has word lengths , , , , , and averages the entropy: bits.
- Telling values apart takes bits, because is too few and is enough.
- The saving per state is , so the total is .
Answer: