Can somebody look into my codes. I am trying to design a small simulation experiment to demonstrate concept of confidence interval for the mean.
function [alpha,m] = CIMV(Me,Sigma,n,alpha)%CIMV= Confidence Interval of Mean Value
%Me=mean, Sigma=standard Deviation, n=record length,
%aplha=confidence interval
X=normrnd(Me,Sigma,[n,100000]);i=0; k=0; Sample=[];for i=1:100000 Me_sample(i)=mean(X(:,i),1); Sigma_sample(i)=std(X(:,i)); Se(i)=Sigma_sample(i)/sqrt(n); % Standard Error
V=tinv(1-0.5*alpha,n-1); Me0(i)=Me_sample(i)-V*Se(i); Me1(i)=Me_sample(i)+V*Se(i); if (Me0(i)<=Me & Me<=Me1(i)) k=k+1; end Sample(1,i)=Me_sample(i); Sample(2,i)=Sigma_sample(i); Sample(3,i)=Se(i); Sample(4,i)=Me0(i); Sample(5,i)=Me1(i); Sample(6,i)=k; end Sampleend
I run by feeding values as mentioned CIMV(0,1,5,.05) however, instead of 5 sample values i am getting 100000.
Best Answer