22-Elec-B3 Digital Communications Systems · December 2016
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Paper format. Professional Engineers of Ontario, Annual Examinations — December 2016, 07-Elec-B3 Digital Communication Systems. Three hours, closed book; a PEO-approved non-programmable calculator (Casio or Sharp approved model) is permitted. Five questions of 25 marks each are printed; any four constitute a complete paper worth 100 marks, and only the first four appearing in the answer book are marked. All five questions are solved here, because the set is a study resource rather than a marked script. Note 1 of the cover page invites the candidate to state any assumption made where a question is open to interpretation — that licence is used explicitly in Question 1.
Reference texts.
Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.
Given. A memoryless source over the eight-letter alphabet $\{A,\dots,H\}$ with
| Letter | A | B | C | D | E | F | G | H |
|---|---|---|---|---|---|---|---|---|
| $\Pr$ | 0.29 | 0.04 | 0.11 | 0.25 | 0.08 | 0.12 | 0.10 | 0.01 |
The probabilities sum to 1.00, as they must.
Find. (a) a Huffman codebook and its average length; (b) the source entropy; (c) a reasoned judgement on a vendor's claim to compress below that entropy.
Approach. Build the code bottom-up by repeatedly merging the two least probable symbols — this is Huffman's algorithm and it is provably optimal among prefix-free codes — then read the codewords off the tree, weight the lengths by probability to get $\bar{L}$, compute the entropy $H(X) = -\sum p_i\log_2 p_i$ independently, and compare the two against the source coding theorem.
| Merge | Nodes combined | New node | Remaining list (probabilities) |
|---|---|---|---|
| 1 | H (0.01) + B (0.04) | 0.05 | 0.29, 0.25, 0.12, 0.11, 0.10, 0.08, 0.05 |
| 2 | 0.05 + E (0.08) | 0.13 | 0.29, 0.25, 0.13, 0.12, 0.11, 0.10 |
| 3 | G (0.10) + C (0.11) | 0.21 | 0.29, 0.25, 0.21, 0.13, 0.12 |
| 4 | F (0.12) + 0.13 | 0.25 | 0.29, 0.25, 0.25, 0.21 |
| 5 | 0.21 + D (0.25) | 0.46 | 0.46, 0.29, 0.25 |
| 6 | 0.25 + A (0.29) | 0.54 | 0.54, 0.46 |
| 7 | 0.46 + 0.54 | 1.00 | root |
| Letter | $p_i$ | Codeword | $\ell_i$ | $p_i\ell_i$ |
|---|---|---|---|---|
| A | 0.29 | 11 | 2 | 0.58 |
| D | 0.25 | 01 | 2 | 0.50 |
| F | 0.12 | 100 | 3 | 0.36 |
| C | 0.11 | 001 | 3 | 0.33 |
| G | 0.10 | 000 | 3 | 0.30 |
| E | 0.08 | 1011 | 4 | 0.32 |
| B | 0.04 | 10101 | 5 | 0.20 |
| H | 0.01 | 10100 | 5 | 0.05 |
| Letter | A | B | C | D | E | F | G | H |
|---|---|---|---|---|---|---|---|---|
| $-p_i\log_2 p_i$ | 0.5179 | 0.1858 | 0.3503 | 0.5000 | 0.2915 | 0.3671 | 0.3322 | 0.0664 |
Part (c) — would you buy the vendor's product? No, not as described. Shannon's source coding theorem makes the entropy of 2.611 bits per letter a hard lower bound on the average rate of any uniquely decodable lossless code for this source, so a vendor promising a smaller average rate on the same memoryless statistics is claiming something provably impossible. There are only three honest ways the claim could be true, and each is a different product from the one advertised: the scheme is lossy, so it is not reproducing the letters exactly; the real source has memory or context that the given single-letter probabilities do not capture, in which case the relevant bound is the lower entropy rate of the true source rather than 2.611 bits per letter; or the quoted figure is a best case on favourable data rather than an average. The right response is therefore to ask which of these applies and to demand a rate measured over representative traffic, rather than to reject the vendor outright — a context-modelling coder beating 2.611 bits per letter on real text is entirely plausible and would simply mean the memoryless model was the wrong yardstick.
| Result | Value |
|---|---|
| (a) Huffman codebook | A = 11, D = 01, F = 100, C = 001, G = 000, E = 1011, B = 10101, H = 10100 |
| (a) Average codeword length $\bar{L}$ | 2.64 bits/letter |
| Fixed-length benchmark | 3 bits/letter (12% worse) |
| (b) Source entropy $H(X)$ | 2.6112 bits/letter |
| Coding efficiency / redundancy | 98.9% / 0.029 bits per letter |
| (c) Buy the product? | No — lossless coding below $H(X)$ is impossible; ask whether it is lossy or exploits memory |