% Problem 8.10.3

yeastObs = load('Problem_8_10_3.dat');
[m, p]   = size(yeastObs);
yeastM   = [m - 1, m - 1, m - 1, m - 1];

for j = 2:5
    
    % a)
    yeastSum                       = sum(yeastObs(:, j));
    yeastLambda                    = sum(yeastObs(:, j).*(0:m - 1)')/yeastSum;
    disp(yeastLambda)
 
    % b)
    yeastSd                        = sqrt(yeastLambda/yeastSum);
    yeastConf                      = [yeastLambda - 1.96*yeastSd, yeastLambda + 1.96*yeastSd];
    disp(yeastConf)
 
    % c)
    yeastExpect                    = yeastSum*poisspdf(0:yeastM(j - 1), yeastLambda)';
    yeastExpect(yeastM(j - 1) + 1) = yeastSum*(1 - sum(poisspdf(0:(yeastM(j - 1) -1), yeastLambda)));
    disp(yeastExpect) 

end

