clear; run=10000; %number of runs. Always do this, instead of having "10000" here and there. e1 = zeros(run,1); e2 = zeros(run,1); e3 = zeros(run,1); for i = 1:run x = 3+randn(5,1); e1(i,:) = [0.2 0.2 0.2 0.2 0.2]*x; e2(i,:) = [0.2 0.3 0.3 0.1 0.1]*x; e3(i,:) = [0.6 0.1 0.1 0.1 0.1]*x; end x= 0.5:0.1:5.5; %specify the x-axis. figure hist(e1, x) figure hist(e2, x) figure hist(e3, x) mean_est = mean([e1 e2 e3]); %mean of the 10000 runs std_est = std([e1 e2 e3]); %standard deviation