Python, Cvxpy, Optimization.
np.array([ [0.1, 0.02, 0.04, 0.03], [0.02, 0.08, 0.01, 0.02], [0.04, 0.01, 0.07, 0.05], [0.03, 0.02, 0.05, 0.09] ]) # Define the objective (maximize return) objective = cp.Maximize(mu @ w) # Define the constraints (weights sum to 1, risk constraint) constraints = [ cp.sum(w) == 1, cp.quad_form(w,