# Seed random number generator srand(1); n = 50; mu_base = 1.05; # mu is linearly spaced from 1.05 + .25 to 1.05 with n points, mu = linspace(mu_base + 0.25, mu_base, n); Sigma = zeros(n,n); sigma_base = .25; # We make each asset be positively and negatively correlated with one # element. S_pre_permute = (circshift(eye(n), 1) + circshift(eye(n), -1) - circshift(eye(n), 2) - circshift(eye(n), -2)); # Random permutation matrix perm = randperm(n); P = eye(n); P = P[perm, :]; S = P' * S_pre_permute * P; # Make sure covariance matrix is positive semidefinite sigma_diag = linspace(sigma_base, 0, n); Sigma = (diagm(sigma_diag) + diagm(sigma_diag.^.5) * S * diagm(sigma_diag.^.5) / 4); Sigma[:, n] = 0; Sigma[n, :] = 0; epsilons = [.1, .05, .01, .005];