% LMcs030401.m
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Case Study 3.4.1 p. 167-168
% Written by Eugene.Gallagher@umb.edu
% Other m.files using exponential distribuion
%    LMEx050302.m 
Tubes=[317 230 118 93 49 33 17 26 20]
% Data not sufficient to reproduce graph
syms y; 
s=int(0.0056*exp(-0.0056*y),500, inf)
P=eval(s)
fprintf(...
'Based on the exponential model, the P(tube life >500) is %5.4f\n',P)
% Since the exponential model describes a pdf
s2=int(0.0056*exp(-0.0056*y),0, 500)
P2=eval(s2)
fprintf(...
'Based on 2nd exponential model, the P(tube life >500) is %5.4f\n',1-P2)
x=0:750;ft=0.0056*exp(-0.0056*x);
edges=[0 80 160 240 320 400 480 560 700];
Tubes=[317 230 118 93 49 33 17 26 20];
Density=Tubes./[diff(edges) 140]./sum(Tubes);
bar(edges,Density,'histc')
hold on
plot(x,ft,'r','LineWidth',2)
axis([0 860 0 0.006])
xlabel('V805 lifetimes (hrs)','FontSize',16)
ylabel('Probability density','FontSize',16)
xf=500:860;yf=0.0056*exp(-0.0056*xf);
fill([500 xf 860]',[0 yf 0]',[.8 .8 1])
title('Figure 3.4.8','FontSize',20)
figure(gcf);pause
hold off
