% straight forward outline of running of scripts %This used the first count observations and predicts expected & the %standard deviation of obs(count+1). display('outline') display('basic parameters') basics_f p(1:3)=[.09 .01 .05]; r= p(2) + p(1)*exp(-p(3).*(0:m+m2)); %r= failure rate rel = exp(-r); %reliabilty of a component pf = 1-rel; %prob component fails before 1 month display('simulating fails per month') fails_per_month_f display('sampling from the prior distribution') obs(1:m+m2) = K(1,1:m+m2); %this gives I observed #failures in months 1:I. Only one obs for each month. % note that the first obs is 0 since 0 fails in first % month. sampling_f for count=no_pred:I %use the first "count" obs to predict the next one. count display('samping from the posterior using importance sampling') post_sampling_f display('sort and display results') sort_disp display('posterior predictive') post_pred_correct end %upper(1:I+1) =post_prediction(1:(I+1)) + 2*sqrt(post_var(1:(I+1))); %lower(1:I+1) =post_prediction(1:(I+1)) - 2*sqrt(post_var(1:(I+1))); figure(111) hold off plot(2:I,obs(2:I),'b.-') hold on plot((no_pred+1):(I+1),post_prediction((no_pred+1):(I+1)),'g.-') plot((no_pred+1):(I+1),upper((no_pred+1):(I+1)),'r.:') plot((no_pred+1):(I+1),lower((no_pred+1):(I+1)),'m.:') plot(I:(I+1),obs(I:(I+1)),'k.:') axis([0 I+2 0 (1.2*n)]) hold off