% 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,:) = [.09 .01 .05]; d(7,:) = [10 5 5]; d(9,:) = [.3 .05 .1]; for count=8:8 %note that now"count" is pretty much useless. Have to run basics again in cross val, over rides setting p=d(count,:) 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+5) = K(1,1:I+5); %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') if c<=I for i=c:I i recreated(count,i,:) = cross_val(i,obs); end observations(count,:) = obs; upper(c:I) =recreated(count,(c:I),1) + recreated(count,(c:I),2); lower(c:I) =recreated(count,(c:I),1) - recreated(count,(c:I),2); hold off figure(count) plot(c:I,recreated(count,c:I),'g.:') hold on plot(c:I,upper(c:I),'xb') plot(c:I,lower(c:I),'xr') plot(2:I,obs(2:I),'k.-') hold on plot(I+1,post_prediction(count),'og') plot(I+1,upper(count),'xb') plot(I+1,lower(count), 'xr') plot((I:I+1),obs(I:I+1),'k.:') hold off else figure(1) hold off plot(2:I,obs(2:I)) plot(I:(I+1),obs(I:(I+1)),'k.:') hold on plot(I+1,post_prediction(count),'dg') plot(I+1,K(1,I+1),'dr') hold off end end