restart:
with(LinearAlgebra):
with(ArrayTools):
with(Statistics):
randomize():
with(plots):
with(combinat):
n := 100:
nstock := 7:
corr := .8:
R := Matrix(nstock, nstock, proc (i, j) options operator, arrow; `if`(i = j, 1, corr) end proc):
CD := Matrix(LUDecomposition(evalf(R), 'method' = 'Cholesky'), datatype = float[8]):
ev := [seq((1/5)*(rand(-3 .. 4))(), i = 1 .. nstock)]:
st := [seq((rand(1 .. 2))(), i = 1 .. nstock)]: