% SAMPLING DISTRIBUTION FOR AN ESTIMATOR OF SIGMA^2 clc; n = 5; loops = 5000; z = zeros(loops,2); for ii = (1:1:loops) x = randn(n,1); s2 = (1/(n-1))*sum((x-mean(x)).^2); sigmahat2 = (1/n)*sum((x-mean(x)).^2); z(ii,1) = s2; z(ii,2) = sigmahat2; end subplot(2,1,1); hist(z(:,1),30); xlim([0,4]); set(gca,'XTick',(0:1:4)); title(['Sampling distribution for s^2 when n = ',num2str(n)]); subplot(2,1,2); hist(z(:,2),30); xlim([0,4]); set(gca,'XTick',(0:1:4)); title(['Sampling Distribution for sigmahat^2 when n = ',num2str(n)]);