function CIRatio() N=1000; % Number of runs to perform InsideCI=0; % Initialize the count of thenumber of means inside the C.I. for runNum=1:N x=randn(1,100); lowerBound=mean(x)-1.96.*std(x)./sqrt(length(x)); upperBound=mean(x)+1.96.*std(x)./sqrt(length(x)); if lowerBound<0 && upperBound >0 InsideCI=InsideCI+1; end end % Because we're finding the 95% confidence interval, the ratio % of the number of means falling outside the confidence interval % should be close to 0.05 (i.e. 5%): RatioOutsideCI=((N-InsideCI)/N)