suc = input('What is the number of successes? ');
fail = input('What is the number of failures? ');
 
thetamax = 0;
likelihoodmax = 0;
 
 for B = 1:1000
    theta(B) = B/1000;
    likelihood(B) = theta(B)^suc*(1 - theta(B))^fail;
    if likelihood(B) > likelihoodmax
        likelihoodmax = likelihood(B);
        thetamax = theta(B);
    end
 end
 for B = 1:1000
     likelihood(B) = likelihood(B)/likelihoodmax;
 end
 begin8 = 99;
 begin32 = 99;
 end8 = 99;
 end32 = 99;
 for B = 1:1000
     if begin8 == 99
         if likelihood(B) > 1/8
             begin8 = theta(B);
         end
     end
     if begin32 == 99
         if likelihood(B) > 1/32
             begin32 = theta(B);
         end
     end
     if and(begin8 ~= 99, end8 == 99)
         if likelihood(B) < 1/8
             end8 = theta(B);
         end
     end
     if and(begin32 ~= 99, end32 == 99)
         if likelihood(B) < 1/32
             end32 = theta(B);
         end
     end
 end
    
     thetamax
     begin32
     end32
     begin8
     end8