Skip to content

Commit b628019

Browse files
authored
'normed' property replaced with 'density' in plt.hist
'normed' property returns Attribute Error! new implementation of matplotlib.pyplot uses 'density' property instead of 'normed' in plt.hist
1 parent 0e07071 commit b628019

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Chapter2_MorePyMC/Ch2_MorePyMC_PyMC3.ipynb

+10-10
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@
442442
"\n",
443443
"\n",
444444
"samples = lambda_1.random(size=20000)\n",
445-
"plt.hist(samples, bins=70, normed=True, histtype=\"stepfilled\")\n",
445+
"plt.hist(samples, bins=70, density=True, histtype=\"stepfilled\")\n",
446446
"plt.title(\"Prior distribution for $\\lambda_1$\")\n",
447447
"plt.xlim(0, 8);"
448448
]
@@ -894,7 +894,7 @@
894894
"figsize(12.5, 4)\n",
895895
"plt.title(\"Posterior distribution of $p_A$, the true effectiveness of site A\")\n",
896896
"plt.vlines(p_true, 0, 90, linestyle=\"--\", label=\"true $p_A$ (unknown)\")\n",
897-
"plt.hist(burned_trace[\"p\"], bins=25, histtype=\"stepfilled\", normed=True)\n",
897+
"plt.hist(burned_trace[\"p\"], bins=25, histtype=\"stepfilled\", density=True)\n",
898898
"plt.legend();"
899899
]
900900
},
@@ -1049,7 +1049,7 @@
10491049
"\n",
10501050
"plt.xlim(0, .1)\n",
10511051
"plt.hist(p_A_samples, histtype='stepfilled', bins=25, alpha=0.85,\n",
1052-
" label=\"posterior of $p_A$\", color=\"#A60628\", normed=True)\n",
1052+
" label=\"posterior of $p_A$\", color=\"#A60628\", density=True)\n",
10531053
"plt.vlines(true_p_A, 0, 80, linestyle=\"--\", label=\"true $p_A$ (unknown)\")\n",
10541054
"plt.legend(loc=\"upper right\")\n",
10551055
"plt.title(\"Posterior distributions of $p_A$, $p_B$, and delta unknowns\")\n",
@@ -1058,13 +1058,13 @@
10581058
"\n",
10591059
"plt.xlim(0, .1)\n",
10601060
"plt.hist(p_B_samples, histtype='stepfilled', bins=25, alpha=0.85,\n",
1061-
" label=\"posterior of $p_B$\", color=\"#467821\", normed=True)\n",
1061+
" label=\"posterior of $p_B$\", color=\"#467821\", density=True)\n",
10621062
"plt.vlines(true_p_B, 0, 80, linestyle=\"--\", label=\"true $p_B$ (unknown)\")\n",
10631063
"plt.legend(loc=\"upper right\")\n",
10641064
"\n",
10651065
"ax = plt.subplot(313)\n",
10661066
"plt.hist(delta_samples, histtype='stepfilled', bins=30, alpha=0.85,\n",
1067-
" label=\"posterior of delta\", color=\"#7A68A6\", normed=True)\n",
1067+
" label=\"posterior of delta\", color=\"#7A68A6\", density=True)\n",
10681068
"plt.vlines(true_p_A - true_p_B, 0, 60, linestyle=\"--\",\n",
10691069
" label=\"true delta (unknown)\")\n",
10701070
"plt.vlines(0, 0, 60, color=\"black\", alpha=0.2)\n",
@@ -1428,7 +1428,7 @@
14281428
"source": [
14291429
"figsize(12.5, 3)\n",
14301430
"p_trace = burned_trace[\"freq_cheating\"][15000:]\n",
1431-
"plt.hist(p_trace, histtype=\"stepfilled\", normed=True, alpha=0.85, bins=30, \n",
1431+
"plt.hist(p_trace, histtype=\"stepfilled\", density=True, alpha=0.85, bins=30, \n",
14321432
" label=\"posterior distribution\", color=\"#348ABD\")\n",
14331433
"plt.vlines([.05, .35], [0, 0], [5, 5], alpha=0.3)\n",
14341434
"plt.xlim(0, 1)\n",
@@ -1559,7 +1559,7 @@
15591559
"source": [
15601560
"figsize(12.5, 3)\n",
15611561
"p_trace = burned_trace[\"freq_cheating\"]\n",
1562-
"plt.hist(p_trace, histtype=\"stepfilled\", normed=True, alpha=0.85, bins=30, \n",
1562+
"plt.hist(p_trace, histtype=\"stepfilled\", density=True, alpha=0.85, bins=30, \n",
15631563
" label=\"posterior distribution\", color=\"#348ABD\")\n",
15641564
"plt.vlines([.05, .35], [0, 0], [5, 5], alpha=0.2)\n",
15651565
"plt.xlim(0, 1)\n",
@@ -1968,12 +1968,12 @@
19681968
"plt.subplot(211)\n",
19691969
"plt.title(r\"Posterior distributions of the variables $\\alpha, \\beta$\")\n",
19701970
"plt.hist(beta_samples, histtype='stepfilled', bins=35, alpha=0.85,\n",
1971-
" label=r\"posterior of $\\beta$\", color=\"#7A68A6\", normed=True)\n",
1971+
" label=r\"posterior of $\\beta$\", color=\"#7A68A6\", density=True)\n",
19721972
"plt.legend()\n",
19731973
"\n",
19741974
"plt.subplot(212)\n",
19751975
"plt.hist(alpha_samples, histtype='stepfilled', bins=35, alpha=0.85,\n",
1976-
" label=r\"posterior of $\\alpha$\", color=\"#A60628\", normed=True)\n",
1976+
" label=r\"posterior of $\\alpha$\", color=\"#A60628\", density=True)\n",
19771977
"plt.legend();"
19781978
]
19791979
},
@@ -2132,7 +2132,7 @@
21322132
"prob_31 = logistic(31, beta_samples, alpha_samples)\n",
21332133
"\n",
21342134
"plt.xlim(0.995, 1)\n",
2135-
"plt.hist(prob_31, bins=1000, normed=True, histtype='stepfilled')\n",
2135+
"plt.hist(prob_31, bins=1000, density=True, histtype='stepfilled')\n",
21362136
"plt.title(\"Posterior distribution of probability of defect, given $t = 31$\")\n",
21372137
"plt.xlabel(\"probability of defect occurring in O-ring\");"
21382138
]

0 commit comments

Comments
 (0)