c f77 bootstrap.f -o bootstrap c This program computes the uncertainty in the mean value of 15 numbers c that do not have individual uncertainties. The uncertainty is c computed via the Bootstrap Method. parameter (Npts=15,Ntrials=10) real A(Npts),A_trial(Npts),mean(Ntrials) integer slot(Npts) data A/7.1,8.3,10.5,4.0,7.7,6.3,12.8,3.3,8.2,10.0,9.2,9.3,6.6, : 7.0,9.6/ idum=-479 ! initialize how many times each slot is selected do j=1,Npts slot(j)=0 enddo do n=1,Ntrials ! randomly select 15 data points do j=1,Npts n_trial=int(ran2(idum)*Npts)+1 !if(n_trial.eq.15) print*,n_trial slot(n_trial)=slot(n_trial)+1 A_trial(j)=a(n_trial) enddo call moment(A_trial,Npts,ave,adev,sdev,var,skew,curt) mean(n)=ave enddo print* print* print'(a16)','The data points:' print*,'7.1 8.3 10.5 4.0 7.7 6.3 12.8 3.3 8.2 10.0 9.2 9.3 6.6 ', : '7.0 9.6' call moment(A,Npts,ave,adev,sdev,var,skew,curt) print 100,'have a mean of ', : ave,'+/-',sdev/sqrt(real(Npts-1)), : ', and a standard deviation of ',sdev 100 format(a15,f4.2,a3,f4.2,a30,f4.2) print* call moment(mean,Ntrials,ave,adev,sdev,var,skew,curt) print'(i7,1x,a24)',Ntrials,'Bootstrap simulations:' print '(a16)','Average Std_Dev' print '(1x,f4.2,5x,f4.2)',ave,sdev print* print*,'Frequency each data point is selected' do j=1,Npts print '(f4.1,1x,f5.2,a1)',A(j), : slot(j)/real(Ntrials)/real(Npts)*100.,'%' enddo end ! of main program include '/usr/local/Numerical_Recipes/recipes_f/recipes/ran2.f' include '/usr/local/Numerical_Recipes/recipes_f/recipes/moment.f'