% Monte Carlo Experiment for the Classical Assumption: E(eps|X)=0 % Parameters and X matrix clc; n = 100; m = 1000; x = (1:1:n)'; beta0 = 1; beta1 = 1; % Loop to Simulate Data and Calculate OLS Estimates b = zeros(m,2); for i = (1:1:m); beta = [beta0;beta1]; X = [ones(n,1) x]; y = X*beta + rand(n,1); b(i,:) = (inv(X'*X)*(X'*y))'; end; % Graph Sampling Distributions subplot(2,1,1); hist(b(:,1),100); subplot(2,1,2); hist(b(:,2),100);