|
442 | 442 | "\n", |
443 | 443 | "\n", |
444 | 444 | "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", |
446 | 446 | "plt.title(\"Prior distribution for $\\lambda_1$\")\n", |
447 | 447 | "plt.xlim(0, 8);" |
448 | 448 | ] |
|
894 | 894 | "figsize(12.5, 4)\n", |
895 | 895 | "plt.title(\"Posterior distribution of $p_A$, the true effectiveness of site A\")\n", |
896 | 896 | "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", |
898 | 898 | "plt.legend();" |
899 | 899 | ] |
900 | 900 | }, |
|
1049 | 1049 | "\n", |
1050 | 1050 | "plt.xlim(0, .1)\n", |
1051 | 1051 | "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", |
1053 | 1053 | "plt.vlines(true_p_A, 0, 80, linestyle=\"--\", label=\"true $p_A$ (unknown)\")\n", |
1054 | 1054 | "plt.legend(loc=\"upper right\")\n", |
1055 | 1055 | "plt.title(\"Posterior distributions of $p_A$, $p_B$, and delta unknowns\")\n", |
|
1058 | 1058 | "\n", |
1059 | 1059 | "plt.xlim(0, .1)\n", |
1060 | 1060 | "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", |
1062 | 1062 | "plt.vlines(true_p_B, 0, 80, linestyle=\"--\", label=\"true $p_B$ (unknown)\")\n", |
1063 | 1063 | "plt.legend(loc=\"upper right\")\n", |
1064 | 1064 | "\n", |
1065 | 1065 | "ax = plt.subplot(313)\n", |
1066 | 1066 | "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", |
1068 | 1068 | "plt.vlines(true_p_A - true_p_B, 0, 60, linestyle=\"--\",\n", |
1069 | 1069 | " label=\"true delta (unknown)\")\n", |
1070 | 1070 | "plt.vlines(0, 0, 60, color=\"black\", alpha=0.2)\n", |
|
1428 | 1428 | "source": [ |
1429 | 1429 | "figsize(12.5, 3)\n", |
1430 | 1430 | "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", |
1432 | 1432 | " label=\"posterior distribution\", color=\"#348ABD\")\n", |
1433 | 1433 | "plt.vlines([.05, .35], [0, 0], [5, 5], alpha=0.3)\n", |
1434 | 1434 | "plt.xlim(0, 1)\n", |
|
1559 | 1559 | "source": [ |
1560 | 1560 | "figsize(12.5, 3)\n", |
1561 | 1561 | "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", |
1563 | 1563 | " label=\"posterior distribution\", color=\"#348ABD\")\n", |
1564 | 1564 | "plt.vlines([.05, .35], [0, 0], [5, 5], alpha=0.2)\n", |
1565 | 1565 | "plt.xlim(0, 1)\n", |
|
1968 | 1968 | "plt.subplot(211)\n", |
1969 | 1969 | "plt.title(r\"Posterior distributions of the variables $\\alpha, \\beta$\")\n", |
1970 | 1970 | "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", |
1972 | 1972 | "plt.legend()\n", |
1973 | 1973 | "\n", |
1974 | 1974 | "plt.subplot(212)\n", |
1975 | 1975 | "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", |
1977 | 1977 | "plt.legend();" |
1978 | 1978 | ] |
1979 | 1979 | }, |
|
2132 | 2132 | "prob_31 = logistic(31, beta_samples, alpha_samples)\n", |
2133 | 2133 | "\n", |
2134 | 2134 | "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", |
2136 | 2136 | "plt.title(\"Posterior distribution of probability of defect, given $t = 31$\")\n", |
2137 | 2137 | "plt.xlabel(\"probability of defect occurring in O-ring\");" |
2138 | 2138 | ] |
|
0 commit comments