For loop taking a long time
<p>I am simulating an Irwin Hall distribution of 1,000,000 replicates, each replicate is a sum of 100 uniform random variables. I created this program and I think its right but MATLAB has been running all night and not finished, so something (obviously) wrong but I can't see where. Here is my program, I hope someone might see the issue.</p>

<pre><code>n=100; % Nb of samples
N=1000000; %Nb of replicates

for jj=1:N
    for ii=1:n
        x(ii)=rand();
    end
    s(jj)=sum(x);
    mu=mean(s);
    sigma2=var(s);
    sigma=std(s);
    S(jj)=1-normcdf((70-mu)/sigma);
    if mod(jj, 100000)==0
        jj
    end
end

histogram(S) 
</code></pre>