% LMex040501_4th.m
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th Edition
% Application of the negative binomial distribuion
% Written by Eugene.Gallagher@umb.edu
% Written 1/9/11
% The California mellows never swing at a pitch and they never try to steal
% when they are on base. What is the expected number of runs, given that
% the opposing pitcher has a probability of 50% of throwing a strike.
P=0.5;
% Calculate the probability of striking out
pso=0;
for k=3:6
    pso=nchoosek(k-1,2)*P^3*P^(k-3)+pso;
end
format rat
pso
format
fprintf('The probability that each batter will strike out is %6.4f.\n',pso)
% Stopped programming here.