Skip to content

Commit 9099908

Browse files
committed
fixed linalg bug
1 parent af7d37e commit 9099908

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cookbook/2-Mean-Variance-Optimisation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2481,7 +2481,7 @@
24812481
"n_samples = 10000\n",
24822482
"w = np.random.dirichlet(np.ones(len(mu)), n_samples)\n",
24832483
"rets = w.dot(mu)\n",
2484-
"stds = np.sqrt(np.diag(w @ S @ w.T))\n",
2484+
"stds = np.sqrt((w.T * (S @ w.T)).sum(axis=0))\n",
24852485
"sharpes = rets / stds\n",
24862486
"\n",
24872487
"print(\"Sample portfolio returns:\", rets)\n",

0 commit comments

Comments
 (0)