|
110 | 110 | "expected value\" )\n", |
111 | 111 | "plt.ylabel(\"average of $n$ samples\")\n", |
112 | 112 | "plt.xlabel(\"# of samples, $n$\")\n", |
113 | | - "plt.legend()\n" |
| 113 | + "plt.legend();" |
114 | 114 | ], |
115 | 115 | "language": "python", |
116 | 116 | "metadata": {}, |
|
185 | 185 | "plt.plot(N_array, np.sqrt(expected_value) / np.sqrt(N_array), lw=2, ls=\"--\",\n", |
186 | 186 | " label=r\"$\\frac{\\sqrt{\\lambda}}{\\sqrt{N}}$\")\n", |
187 | 187 | "plt.legend()\n", |
188 | | - "plt.title(\"How 'fast' is the sample average converging? \")\n" |
| 188 | + "plt.title(\"How 'fast' is the sample average converging? \");" |
189 | 189 | ], |
190 | 190 | "language": "python", |
191 | 191 | "metadata": {}, |
|
244 | 244 | "input": [ |
245 | 245 | "import pymc as pm\n", |
246 | 246 | "N = 10000\n", |
247 | | - "print np.mean([pm.rexponential(0.5) > 10 for i in range(N)])\n" |
| 247 | + "print np.mean([pm.rexponential(0.5) > 10 for i in range(N)]);" |
248 | 248 | ], |
249 | 249 | "language": "python", |
250 | 250 | "metadata": {}, |
|
333 | 333 | "plt.ylabel(\"Average height in county\")\n", |
334 | 334 | "plt.plot([100, 1500], [150, 150], color=\"k\", label=\"true expected \\\n", |
335 | 335 | "height\", ls=\"--\")\n", |
336 | | - "plt.legend(scatterpoints=1)\n" |
| 336 | + "plt.legend(scatterpoints=1);" |
337 | 337 | ], |
338 | 338 | "language": "python", |
339 | 339 | "metadata": {}, |
|
366 | 366 | "print population[np.argsort(average_across_county)[:10]]\n", |
367 | 367 | "print\n", |
368 | 368 | "print \"Population sizes of 10 'tallest' counties: \"\n", |
369 | | - "print population[np.argsort(-average_across_county)[:10]]\n" |
| 369 | + "print population[np.argsort(-average_across_county)[:10]];" |
370 | 370 | ], |
371 | 371 | "language": "python", |
372 | 372 | "metadata": {}, |
|
419 | 419 | " edgecolors=\"#A60628\", linewidths=1.5,\n", |
420 | 420 | " label=\"most extreme points\")\n", |
421 | 421 | "\n", |
422 | | - "plt.legend(scatterpoints=1)\n" |
| 422 | + "plt.legend(scatterpoints=1);" |
423 | 423 | ], |
424 | 424 | "language": "python", |
425 | 425 | "metadata": {}, |
|
498 | 498 | "# adding a number to the end of the %run call with get the ith top photo.\n", |
499 | 499 | "%run top_pic_comments.py 2\n", |
500 | 500 | "\n", |
501 | | - "Image(top_post_url)\n" |
| 501 | + "Image(top_post_url);" |
502 | 502 | ], |
503 | 503 | "language": "python", |
504 | 504 | "metadata": {}, |
|
537 | 537 | "for i in comments:\n", |
538 | 538 | " print '\"' + contents[i] + '\"'\n", |
539 | 539 | " print\"upvotes/downvotes: \", votes[i, :]\n", |
540 | | - " print\n" |
| 540 | + " print;" |
541 | 541 | ], |
542 | 542 | "language": "python", |
543 | 543 | "metadata": {}, |
|
596 | 596 | " map_ = pm.MAP([upvote_ratio, observations]).fit()\n", |
597 | 597 | " mcmc = pm.MCMC([upvote_ratio, observations])\n", |
598 | 598 | " mcmc.sample(samples, samples / 4)\n", |
599 | | - " return mcmc.trace(\"upvote_ratio\")[:]\n" |
| 599 | + " return mcmc.trace(\"upvote_ratio\")[:];" |
600 | 600 | ], |
601 | 601 | "language": "python", |
602 | 602 | "metadata": {}, |
|
628 | 628 | "\n", |
629 | 629 | "plt.legend(loc=\"upper left\")\n", |
630 | 630 | "plt.xlim(0, 1)\n", |
631 | | - "plt.title(\"Posterior distributions of upvote ratios on different comments\")\n" |
| 631 | + "plt.title(\"Posterior distributions of upvote ratios on different comments\");" |
632 | 632 | ], |
633 | 633 | "language": "python", |
634 | 634 | "metadata": {}, |
|
695 | 695 | "plt.legend(loc=\"upper left\")\n", |
696 | 696 | "plt.title(\"Posterior distributions of upvote ratios on different comments\")\n", |
697 | 697 | "order = np.argsort(-np.array(lower_limits))\n", |
698 | | - "print order, lower_limits\n" |
| 698 | + "print order, lower_limits;" |
699 | 699 | ], |
700 | 700 | "language": "python", |
701 | 701 | "metadata": {}, |
|
767 | 767 | "for i in order[:40]:\n", |
768 | 768 | " ordered_contents.append(contents[i])\n", |
769 | 769 | " print votes[i, 0], votes[i, 1], contents[i]\n", |
770 | | - " print \"-------------\"\n" |
| 770 | + " print \"-------------\";" |
771 | 771 | ], |
772 | 772 | "language": "python", |
773 | 773 | "metadata": {}, |
|
906 | 906 | " color=\"#7A68A6\")\n", |
907 | 907 | "plt.xlim(0.3, 1)\n", |
908 | 908 | "plt.yticks(np.arange(len(r_order) - 1, -1, -1),\n", |
909 | | - " map(lambda x: x[:30].replace(\"\\n\", \"\"), ordered_contents))\n" |
| 909 | + " map(lambda x: x[:30].replace(\"\\n\", \"\"), ordered_contents));" |
910 | 910 | ], |
911 | 911 | "language": "python", |
912 | 912 | "metadata": {}, |
|
1020 | 1020 | "exp = stats.expon(scale=4)\n", |
1021 | 1021 | "N = 1e5\n", |
1022 | 1022 | "X = exp.rvs(N)\n", |
1023 | | - "# ...\n" |
| 1023 | + "# ...;" |
1024 | 1024 | ], |
1025 | 1025 | "language": "python", |
1026 | 1026 | "metadata": {}, |
|
1101 | 1101 | "def css_styling():\n", |
1102 | 1102 | " styles = open(\"../styles/custom.css\", \"r\").read()\n", |
1103 | 1103 | " return HTML(styles)\n", |
1104 | | - "css_styling()\n" |
| 1104 | + "css_styling();" |
1105 | 1105 | ], |
1106 | 1106 | "language": "python", |
1107 | 1107 | "metadata": {}, |
|
0 commit comments