%LMex070401_4th.m
X=[2.5 0.1 0.2 1.3
    3.2 0.1 0.1 1.4
0.5 0.2 0.4 11.2
0.4 7.4 1.8 2.1
0.3 8.6 0.3 10.1]; X=X(:);
[H,P,CI,STATS]=ttest(X,0,0.05,'both');
fprintf('The sample arithmetic mean is %6.4f\n',mean(X))
fprintf('The 95%% confidence interval is (%6.4f %6.4f)\n',CI)
Binsize=1;
edges=0:Binsize:ceil(max(X));
[N1,BIN1] = histc(X,edges);
bar(edges,N1,'histc');
axis([0 12.5 0 11]);
set(get(gca,'Children'),'FaceColor',[.8 .8 1])
ylabel('Frequency','FontSize',20);
ax1=gca;set(ax1,'xtick',0:5:10,'FontSize',20);
set(ax1,'ytick',0:5:10,'FontSize',20)
title('Figure 7.4.3','FontSize',22)
figure(gcf);pause
% Matlab's boxplot and norm pdf are also very good at determining if
% samples have nonnormal distributions.
boxplot(X); pause
normplot(X);pause

% ----
% Optional. A log transform makes these data suitable for analysis with the
% t tools
lx=log(X);
boxplot(lx); pause
normplot(lx);pause
edges=-3:3;
[N1,BIN1] = histc(lx,edges);
bar(edges,N1,'histc');axis([-3.1 3.1 0 5.1]);
set(get(gca,'Children'),'FaceColor',[.8 .8 1])
ylabel('Frequency','FontSize',20);
ax1=gca;set(ax1,'xtick',-3:3,'FontSize',20);
set(ax1,'ytick',0:5:10,'FontSize',20);
title('Figure 7.4.3b','FontSize',22);figure(gcf)
[H,P,CI,STATS]=ttest(lx);
fprintf('\nThe geometric mean is %6.4f\n',exp(mean(lx)))
fprintf('The 95%% confidence interval is (%6.4f %6.4f)\n',exp(CI))