Problem 1 a. i. P(circular) = (1 - P(square)) = 1 - .6^2 = 0.64% ii. P(square) = .6^2 = 0.36 iii. P(blue) = .5^2 = 0.25 iv. P(red) = 1 - P(blue) = .75 b. i. P(blue) still = 0.25 ii. P(red) still = .75 c. also independant i. P(square) still = 0.36 ii. P(circular) still = 0.64% d. T = tested positive M = mutant P(T | M) = 0.9 P(T | ~M) = 0.005 P(M) = 0.001 We are looking for P(M | T): P(T | M) = P(T ^ M) / P(M) P(T | ~M) = P(T ^ ~M) / P(~M) P(M | T) = P(T ^ M) / P(T) P(T ^ M) = P(T | M) * P(M) = 0.9 * 0.001 = 0.0009 P(T) = P(T | M) + P(T | ~M) = 0.9 + 0.005 = 0.905 P(M | T) = 0.0009 / 0.905 = 0.0994 / 100 (!!!) Probem 2 a. Each character would need 3 (log2(8)) bits. The phrase would need 84 (28 * 3) bits. b. Theorecal min number of bits required %% MatLab M = [35.71 14.29 10.71 17.86 3.57 3.57 3.57 10.71]./100 P = M .* log2(1./M) n = sum(P) Thus n = 2.5808 c. P = [0.5305 0.4011 0.3452 0.4439 0.1716 0.1716 0.1716 0.3452] d. {C="" 0.3571} {F="" 0.1789} {D="" 0.1429} {E="" 0.1071} {R="" 0.1071} {G="" 0.0357} {A="" 0.0357} {C+="" 0.0357} {C="" 0.3571} {F="" 0.1789} {D="" 0.1429} {E="" 0.1071} {R="" 0.1071} {G="" 0.0357} {A=1 C+=0 0.0714} {C="" 0.3571} {F="" 0.1789} {D="" 0.1429} {E="" 0.1071} {R="" 0.1071} {G=1 A=01 C+=00 0.1071} {C="" 0.3571} {F="" 0.1789} {D="" 0.1429} {E="" 0.1071} {R=1 G=01 A=001 C+=000 0.2142} {C="" 0.3571} {F="" 0.1789} {D="" 0.1429} {E=1 R=01 G=001 A=0001 C+=0000 0.3213} {C="" 0.3571} {F="" 0.1789} {D=1 E=01 R=001 G=0001 A=00001 C+=00000 0.4642} {C="" 0.3571} {F=1 D=01 E=001 R=0001 G=00001 A=000001 C+=000000 0.6429} {C=1 F=01 D=001 E=0001 R=00001 G=000001 A=0000001 C+=0000000 1} Thus: Code Length Occurrences Bits Needed C 1 1 10 10 F 01 2 5 10 D 001 3 4 12 E 0001 4 3 12 R 00001 5 3 15 G 000001 6 1 6 A 0000001 7 1 7 C+ 0000000 7 1 7 Total 28 79 e. i. 79 bits are needed ii. Fixed length code required 84 bits, thus the huffman encoding is a little more efficient. iii. 2.5810 * 28 = 72.268; Not as efficient, obviously, not too far off either.