The following Matlab code was used to investigate the claim that the random number generator randn generates
samples of a ZERO-MEAN random variable. The intent here is to give you an idea of how a specific analysis
might proceed, and to familiarize you with some useful Matlab commands.
% PROGRAM NAME: HW_1
% PURPOSE: To investigate the claim that the randn
% command really does generate a ZERO MEAN random variable
% METHOD: Estimate the 3-sigma range for the estimator
% of the mean using n iid random variables. It should
% become increasingly localized about the true unknown
% mean as n approaches infinity.
% ==============================
xlow=[]; % initialize range limit vector
xhigh=[];
nvec=[];
for i=1:3
n=10^i; % number of iid r.v.s averaged
nvec=[nvec,n];
xmat=randn(n,1000); % generate 1000 realizations of n-vector
xbar=mean(xmat); % compute 1000 measurements of xbar
xlow=[xlow,mean(xbar)-3*std(xbar)]; %essential lower limit of range of xbar
xhigh=[xhigh,mean(xbar)+3*std(xbar)];%essential upper limit of range of xbar
end
plot(log10(nvec),[xlow;xhigh])
xlabel('Base-10 log of number averaged')
title('Estimated 3-sigma range for xbar(n) versus log(n)')