%% ps1 % pD + pT + pK = 1 % 900 pD + 1500 pT + 2100 pK = 1600 % a. % i. % pK max = 7/12 = 0.5833 solve('2100 * x + 900 * (1 - x) = 1600', 'x') % pK min = 1/ 6 = 0.1667 solve('2100 * x + 1500 * (1 - x) = 1600', 'x') % 1/6 <= pK <= 7/12 % ii. % pD = (-1 + 6 pK)/6 % pT = ( 7 - 12 pK)/6 % [pD,pT] = solve('pD + pT + pK = 1', '900*pD + 1500*pT + 2100*pK = 1600', 'pD,pT') pK = 1/6:0.01:7/12 hD = (-1+6.*pK)./6 .* log(6./(-1+6.*pK))./log(2); hT = (7-12.*pK)./6 .* log(6./(7-12.*pK))./log(2); hK = pK .* log(1./pK) ./log(2); H = hD + hT + hK % plot(pK, H) % iii. % max(H) % 1.5546 solve('diff((-1+6*pK)/6 * log(6/(-1+6*pK))/log(2) + (7-12*pK)/6 * log(6/(7-12*pK))/log(2) + pK * log(1/pK)/log(2),pK)=0','pK') pK = 0.4202 pD = (-1 + 6*pK)/6 % 0.2535 pT = ( 7 - 12*pK)/6 % 0.3263 h = (-1+6*pK)/6 * log(6/(-1+6*pK))/log(2) + (7-12*pK)/6 * log(6/(7-12*pK))/log(2) + pK * log(1/pK)/log(2) % 1.5546 [OK] % b. The entropy must be less than the max entropy, since more information is assumed for this computation. % c. pK = 0.5833 pD = (-1 + 6*pK)/6 % 0.4166 pT = ( 7 - 12*pK)/6 % 6.667e-05 h = (-1+6*pK)/6 * log(6/(-1+6*pK))/log(2) + (7-12*pK)/6 * log(6/(7-12*pK))/log(2) + pK * log(1/pK)/log(2) % 0.9808 [OK] % d. % The absolute min number of pages is simply 0; % the average for the other weeks has then to be 1600 * nWeeks / (nWeeks - 1) to maintain an 1600 average per week. % From the three possible books, the min number of pages is 900; % the average for the other weeks has then to be (1600 * nWeeks - 900) / (nWeeks - 1). % d. % The absolute max number of pages is 1600 * nWeeks; % that is all the assignments are done the first week (!). % From the three possible books, the max number of pages is 2100; % the average for the other weeks has then to be (1600 * nWeeks - 1200) / (nWeeks - 1). %% ps2 % mass [g] % nickel % nickel 5 25 % quarter 5+2/3 8.33 % dollar 8.1 12.5 % % pN + pQ + pD = 1 % 5 nN + 17/3 nQ + 8.1 nD = 2300 % a. % nN: 0 to 460 % nQ: 0 to 405 (+ 1 n) % nD: 0 to 280 (+ 3 n + 3q) % b. % nN + nQ + nD = 400 [nQ, nD] = solve('nN + nQ + nD = 400', '5*nN + (17/3)*nQ + 8.1*nD = 2300', 'nQ,nD') nN = 0:1:460; nQ = 0.273972 * nN + 13.69863 nD = -1.273972 * nN + 386.30137 pN = nN/400; pQ = nQ/400; pD = nD/400; H = pN.*log(1./pN)./log(2) + pQ.*log(1./pQ)./log(2) + pD.*log(1./pD)./log(2) max(real(H)) % 1.4693 % max: H(188) nN(188) % 187 nQ(188) % 65 nD(188) % 148 % c. mNi = (nN(188) * 5 * .25 + nQ(188) * 17/3 * .0833 + nD(188) * 8.1 * .125) / (nN(188) * 5 + nQ(188) * 17/3 + nD(188) * 8.1) % 16.56% mCu = 1 - mNi % 83.44% % d. We cannot have 200 dollar coins, if the jar is to contain 400 coins and weight 2300 grams. % Indeed, we only need 136 (2300 - 200 * 8.1)/5) nickels to meet the 2300 grams, % while having not reached 400 coins. % Our answer is not compatible with a, but that is OK, % because in a we didn't have any indications on the total number of coins.