|
360 | 360 | "\n", |
361 | 361 | "\n", |
362 | 362 | "samples = [lambda_1.random() for i in range(20000)]\n", |
363 | | - "plt.hist(samples, bins=70, normed=True, histtype=\"stepfilled\")\n", |
| 363 | + "plt.hist(samples, bins=70, density=True, histtype=\"stepfilled\")\n", |
364 | 364 | "plt.title(\"Prior distribution for $\\lambda_1$\")\n", |
365 | 365 | "plt.xlim(0, 8);" |
366 | 366 | ] |
|
826 | 826 | "figsize(12.5, 4)\n", |
827 | 827 | "plt.title(\"Posterior distribution of $p_A$, the true effectiveness of site A\")\n", |
828 | 828 | "plt.vlines(p_true, 0, 90, linestyle=\"--\", label=\"true $p_A$ (unknown)\")\n", |
829 | | - "plt.hist(mcmc.trace(\"p\")[:], bins=25, histtype=\"stepfilled\", normed=True)\n", |
| 829 | + "plt.hist(mcmc.trace(\"p\")[:], bins=25, histtype=\"stepfilled\", density=True)\n", |
830 | 830 | "plt.legend();" |
831 | 831 | ] |
832 | 832 | }, |
|
979 | 979 | "\n", |
980 | 980 | "plt.xlim(0, .1)\n", |
981 | 981 | "plt.hist(p_A_samples, histtype='stepfilled', bins=25, alpha=0.85,\n", |
982 | | - " label=\"posterior of $p_A$\", color=\"#A60628\", normed=True)\n", |
| 982 | + " label=\"posterior of $p_A$\", color=\"#A60628\", density=True)\n", |
983 | 983 | "plt.vlines(true_p_A, 0, 80, linestyle=\"--\", label=\"true $p_A$ (unknown)\")\n", |
984 | 984 | "plt.legend(loc=\"upper right\")\n", |
985 | 985 | "plt.title(\"Posterior distributions of $p_A$, $p_B$, and delta unknowns\")\n", |
|
988 | 988 | "\n", |
989 | 989 | "plt.xlim(0, .1)\n", |
990 | 990 | "plt.hist(p_B_samples, histtype='stepfilled', bins=25, alpha=0.85,\n", |
991 | | - " label=\"posterior of $p_B$\", color=\"#467821\", normed=True)\n", |
| 991 | + " label=\"posterior of $p_B$\", color=\"#467821\", density=True)\n", |
992 | 992 | "plt.vlines(true_p_B, 0, 80, linestyle=\"--\", label=\"true $p_B$ (unknown)\")\n", |
993 | 993 | "plt.legend(loc=\"upper right\")\n", |
994 | 994 | "\n", |
995 | 995 | "ax = plt.subplot(313)\n", |
996 | 996 | "plt.hist(delta_samples, histtype='stepfilled', bins=30, alpha=0.85,\n", |
997 | | - " label=\"posterior of delta\", color=\"#7A68A6\", normed=True)\n", |
| 997 | + " label=\"posterior of delta\", color=\"#7A68A6\", density=True)\n", |
998 | 998 | "plt.vlines(true_p_A - true_p_B, 0, 60, linestyle=\"--\",\n", |
999 | 999 | " label=\"true delta (unknown)\")\n", |
1000 | 1000 | "plt.vlines(0, 0, 60, color=\"black\", alpha=0.2)\n", |
|
1353 | 1353 | "source": [ |
1354 | 1354 | "figsize(12.5, 3)\n", |
1355 | 1355 | "p_trace = mcmc.trace(\"freq_cheating\")[:]\n", |
1356 | | - "plt.hist(p_trace, histtype=\"stepfilled\", normed=True, alpha=0.85, bins=30,\n", |
| 1356 | + "plt.hist(p_trace, histtype=\"stepfilled\", density=True, alpha=0.85, bins=30,\n", |
1357 | 1357 | " label=\"posterior distribution\", color=\"#348ABD\")\n", |
1358 | 1358 | "plt.vlines([.05, .35], [0, 0], [5, 5], alpha=0.3)\n", |
1359 | 1359 | "plt.xlim(0, 1)\n", |
|
1479 | 1479 | "source": [ |
1480 | 1480 | "figsize(12.5, 3)\n", |
1481 | 1481 | "p_trace = mcmc.trace(\"freq_cheating\")[:]\n", |
1482 | | - "plt.hist(p_trace, histtype=\"stepfilled\", normed=True, alpha=0.85, bins=30,\n", |
| 1482 | + "plt.hist(p_trace, histtype=\"stepfilled\", density=True, alpha=0.85, bins=30,\n", |
1483 | 1483 | " label=\"posterior distribution\", color=\"#348ABD\")\n", |
1484 | 1484 | "plt.vlines([.05, .35], [0, 0], [5, 5], alpha=0.2)\n", |
1485 | 1485 | "plt.xlim(0, 1)\n", |
|
1910 | 1910 | "plt.subplot(211)\n", |
1911 | 1911 | "plt.title(r\"Posterior distributions of the variables $\\alpha, \\beta$\")\n", |
1912 | 1912 | "plt.hist(beta_samples, histtype='stepfilled', bins=35, alpha=0.85,\n", |
1913 | | - " label=r\"posterior of $\\beta$\", color=\"#7A68A6\", normed=True)\n", |
| 1913 | + " label=r\"posterior of $\\beta$\", color=\"#7A68A6\", density=True)\n", |
1914 | 1914 | "plt.legend()\n", |
1915 | 1915 | "\n", |
1916 | 1916 | "plt.subplot(212)\n", |
1917 | 1917 | "plt.hist(alpha_samples, histtype='stepfilled', bins=35, alpha=0.85,\n", |
1918 | | - " label=r\"posterior of $\\alpha$\", color=\"#A60628\", normed=True)\n", |
| 1918 | + " label=r\"posterior of $\\alpha$\", color=\"#A60628\", density=True)\n", |
1919 | 1919 | "plt.legend();" |
1920 | 1920 | ] |
1921 | 1921 | }, |
|
2074 | 2074 | "prob_31 = logistic(31, beta_samples, alpha_samples)\n", |
2075 | 2075 | "\n", |
2076 | 2076 | "plt.xlim(0.995, 1)\n", |
2077 | | - "plt.hist(prob_31, bins=1000, normed=True, histtype='stepfilled')\n", |
| 2077 | + "plt.hist(prob_31, bins=1000, density=True, histtype='stepfilled')\n", |
2078 | 2078 | "plt.title(\"Posterior distribution of probability of defect, given $t = 31$\")\n", |
2079 | 2079 | "plt.xlabel(\"probability of defect occurring in O-ring\");" |
2080 | 2080 | ] |
|
0 commit comments