% straight forward outline of running of scripts d(1,:) = [.01 .005 1]; d(2,:) = [.01 .005 .1]; d(3,:) = [.9 .01 .01]; d(5,:) = [.9 .01 1]; d(10,:) = [.05 .005 .1]; %d(6,:) = [.05 .01 .5]; d(6,:) = [.3 .05 .1]; d(8,:) = [.9 .01 .05]; d(7,:) = [10 5 5]; d(9,:) = [.3 .05 .1]; for count=8:10 count display('outline') display('basic parameters') basics_f p(1:3)=d(count,:) 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:I) = K(1,1:I); %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 display('samping from the posterior using importance sampling') post_sampling_f display('sort and display results') sort_disp display('posterior predictive') post_pred display('cross validation') for i=c:I i recreated(count,i) = cross_val(i,obs); end observations(count,:) = obs; hold off figure(count) plot(c:I,recreated(count,c:I),'dg') hold on plot(1:I,obs) hold on plot(I+1,post_prediction(I+1),'dg') plot(I+1,K(1,I+1),'dr') hold off end