Skip to content

Commit

Permalink
fixing notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
tschm committed Nov 27, 2024
1 parent 2d9172a commit 50f117d
Show file tree
Hide file tree
Showing 4 changed files with 321 additions and 303 deletions.
538 changes: 278 additions & 260 deletions book/docs/notebooks/demo.ipynb

Large diffs are not rendered by default.

76 changes: 38 additions & 38 deletions book/docs/notebooks/factormodel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"import numpy as np\n",
"import cvxpy as cvx\n",
"\n",
"from cvx.linalg import pca\n",
"from cvx.risk.linalg import pca\n",
"from cvx.risk.factor import FactorModel\n",
"from cvx.portfolio.min_risk import minrisk_problem"
]
Expand Down Expand Up @@ -142,7 +142,7 @@
{
"data": {
"text/plain": [
"0.00923407730537884"
"np.float64(0.009234077305378861)"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -197,30 +197,30 @@
"name": "stdout",
"output_type": "stream",
"text": [
"GOOG 2.359232e-09\n",
"AAPL 1.078173e-02\n",
"FB 2.289733e-09\n",
"BABA 6.149695e-02\n",
"AMZN 4.095655e-02\n",
"GE 1.692077e-03\n",
"AMD 9.033789e-10\n",
"WMT 4.448612e-02\n",
"BAC 1.048329e-09\n",
"GM 1.137605e-09\n",
"T 1.297920e-01\n",
"UAA 9.633963e-10\n",
"SHLD 7.309925e-10\n",
"XOM 2.502608e-01\n",
"RRC 1.020484e-09\n",
"BBY 1.392779e-02\n",
"MA 5.914576e-02\n",
"PFE 2.364381e-01\n",
"JPM 3.743304e-09\n",
"SBUX 1.510221e-01\n",
"GOOG 5.654445e-09\n",
"AAPL 1.078298e-02\n",
"FB 5.488994e-09\n",
"BABA 6.149758e-02\n",
"AMZN 4.095639e-02\n",
"GE 1.694607e-03\n",
"AMD 2.165087e-09\n",
"WMT 4.448256e-02\n",
"BAC 2.516558e-09\n",
"GM 2.730308e-09\n",
"T 1.297914e-01\n",
"UAA 2.310979e-09\n",
"SHLD 1.733013e-09\n",
"XOM 2.502611e-01\n",
"RRC 2.457944e-09\n",
"BBY 1.392807e-02\n",
"MA 5.914495e-02\n",
"PFE 2.364385e-01\n",
"JPM 8.938543e-09\n",
"SBUX 1.510218e-01\n",
"dtype: float64\n",
"0.006799927138118909\n",
"[ 0.04251146 -0.09313427 -0.03753803 0.08220467 0.08363908 -0.02800705\n",
" -0.1 -0.0717266 0.09784121 -0.03309495]\n"
"0.006799927163237368\n",
"[ 0.04251151 0.09313457 0.03753817 0.08220493 -0.08363883 -0.0280072\n",
" -0.1 -0.07172425 0.09783884 0.03309744]\n"
]
}
],
Expand Down Expand Up @@ -257,8 +257,8 @@
{
"data": {
"text/plain": [
"array([ 0.04251146, -0.09313427, -0.03753803, 0.08220467, 0.08363908,\n",
" -0.02800705, -0.1 , -0.0717266 , 0.09784121, -0.03309495])"
"array([ 0.04251151, 0.09313457, 0.03753817, 0.08220493, -0.08363883,\n",
" -0.0280072 , -0.1 , -0.07172425, 0.09783884, 0.03309744])"
]
},
"execution_count": 6,
Expand Down Expand Up @@ -287,8 +287,8 @@
{
"data": {
"text/plain": [
"array([ 0.04251146, -0.09313427, -0.03753803, 0.08220467, 0.08363908,\n",
" -0.02800705, -0.1 , -0.0717266 , 0.09784121, -0.03309495])"
"array([ 0.04251151, 0.09313457, 0.03753817, 0.08220493, -0.08363883,\n",
" -0.0280072 , -0.1 , -0.07172425, 0.09783884, 0.03309744])"
]
},
"execution_count": 7,
Expand Down Expand Up @@ -333,8 +333,8 @@
{
"data": {
"text/plain": [
"array([ 0.04251146, -0.09313427, -0.03753803, 0.08220467, 0.08363908,\n",
" -0.02800705, -0.1 , -0.0717266 , 0.09784121, -0.03309495])"
"array([ 0.04251151, 0.09313457, 0.03753817, 0.08220493, -0.08363883,\n",
" -0.0280072 , -0.1 , -0.07172425, 0.09783884, 0.03309744])"
]
},
"execution_count": 8,
Expand Down Expand Up @@ -363,8 +363,8 @@
{
"data": {
"text/plain": [
"array([ 0.04251146, -0.09313427, -0.03753803, 0.08220467, 0.08363908,\n",
" -0.02800705, -0.1 , -0.0717266 , 0.09784121, -0.03309495])"
"array([ 0.04251151, 0.09313457, 0.03753817, 0.08220493, -0.08363883,\n",
" -0.0280072 , -0.1 , -0.07172425, 0.09783884, 0.03309744])"
]
},
"execution_count": 9,
Expand Down Expand Up @@ -401,8 +401,8 @@
{
"data": {
"text/plain": [
"array([ 0.04251146, -0.09313427, -0.03753803, 0.08220467, 0.08363908,\n",
" -0.02800705, -0.1 , -0.0717266 , 0.09784121, -0.03309495])"
"array([ 0.04251151, 0.09313457, 0.03753817, 0.08220493, -0.08363883,\n",
" -0.0280072 , -0.1 , -0.07172425, 0.09783884, 0.03309744])"
]
},
"execution_count": 10,
Expand All @@ -423,8 +423,8 @@
{
"data": {
"text/plain": [
"array([ 0.04251146, -0.09313427, -0.03753803, 0.08220467, 0.08363908,\n",
" -0.02800705, -0.1 , -0.0717266 , 0.09784121, -0.03309495])"
"array([ 0.04251151, 0.09313457, 0.03753817, 0.08220493, -0.08363883,\n",
" -0.0280072 , -0.1 , -0.07172425, 0.09783884, 0.03309744])"
]
},
"execution_count": 11,
Expand Down Expand Up @@ -461,7 +461,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions book/docs/notebooks/large.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"639 ms ± 23.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
"150 ms ± 940 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
]
}
],
Expand Down Expand Up @@ -204,7 +204,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions book/docs/notebooks/sample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"811 ms ± 124 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
"270 ms ± 9.77 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
Expand Down Expand Up @@ -112,7 +112,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"3.94 s ± 47.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
"2.02 s ± 36.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
Expand Down Expand Up @@ -154,7 +154,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 50f117d

Please sign in to comment.