|
12 | 12 | "collapsed": false, |
13 | 13 | "input": [ |
14 | 14 | "figsize(12.5, 4)\n", |
15 | | - "import scipy.stats as stats\n" |
| 15 | + "import scipy.stats as stats;" |
16 | 16 | ], |
17 | 17 | "language": "python", |
18 | 18 | "metadata": {}, |
|
48 | 48 | "cell_type": "code", |
49 | 49 | "collapsed": false, |
50 | 50 | "input": [ |
51 | | - "run github_datapull.py\n" |
| 51 | + "run github_datapull.py;" |
52 | 52 | ], |
53 | 53 | "language": "python", |
54 | 54 | "metadata": {}, |
|
350 | 350 | "plt.title(\"Popularity of Repos (as measured by stars and forks)\")\n", |
351 | 351 | "plt.xlabel(\"$K$\")\n", |
352 | 352 | "plt.ylabel(\"number of repos with stars/forks $K$\")\n", |
353 | | - "plt.xlim(-200, 35000)\n" |
| 353 | + "plt.xlim(-200, 35000);" |
354 | 354 | ], |
355 | 355 | "language": "python", |
356 | 356 | "metadata": {}, |
|
385 | 385 | "plt.legend(loc=\"upper right\")\n", |
386 | 386 | "plt.title(\"Log-Log plot of Popularity of Repos (as measured by stars and forks)\")\n", |
387 | 387 | "plt.xlabel(\"$\\log{K}$\")\n", |
388 | | - "plt.ylabel(\"$\\log$(number of repos with stars/forks < K )\")\n" |
| 388 | + "plt.ylabel(\"$\\log$(number of repos with stars/forks < K )\");" |
389 | 389 | ], |
390 | 390 | "language": "python", |
391 | 391 | "metadata": {}, |
|
473 | 473 | "model = pm.Model([param, yule_simon])\n", |
474 | 474 | "mcmc = pm.MCMC(model)\n", |
475 | 475 | "\n", |
476 | | - "mcmc.sample(10000, 8000)\n" |
| 476 | + "mcmc.sample(10000, 8000);" |
477 | 477 | ], |
478 | 478 | "language": "python", |
479 | 479 | "metadata": {}, |
|
501 | 501 | "def logp(value, rho):\n", |
502 | 502 | " return np.log(rho) + np.log(beta(value, rho + 1))\n", |
503 | 503 | "\n", |
504 | | - "beta(repo_with_stars, 1.3)\n" |
| 504 | + "beta(repo_with_stars, 1.3);" |
505 | 505 | ], |
506 | 506 | "language": "python", |
507 | 507 | "metadata": {}, |
|
537 | 537 | "plt.plot(x, exp(-(x - 1) ** 2), label=\"Normal distribution\")\n", |
538 | 538 | "plt.plot(x, x ** (-2), label=r\"Power law, $\\beta = -2$\")\n", |
539 | 539 | "plt.plot(x, x ** (-1), label=r\"Power law, $\\beta = -1$\")\n", |
540 | | - "plt.legend()\n" |
| 540 | + "plt.legend();" |
541 | 541 | ], |
542 | 542 | "language": "python", |
543 | 543 | "metadata": {}, |
|
574 | 574 | "def css_styling():\n", |
575 | 575 | " styles = open(\"../styles/custom.css\", \"r\").read()\n", |
576 | 576 | " return HTML(styles)\n", |
577 | | - "css_styling()\n" |
| 577 | + "css_styling();" |
578 | 578 | ], |
579 | 579 | "language": "python", |
580 | 580 | "metadata": {}, |
|
662 | 662 | "\n", |
663 | 663 | "@pm.observed\n", |
664 | 664 | "def survival(value=y_, beta=beta):\n", |
665 | | - " return np.sum([value[i - 1] * np.log((i + 0.) ** beta - (i + 1.) ** beta) for i in range(1, 99)])\n" |
| 665 | + " return np.sum([value[i - 1] * np.log((i + 0.) ** beta - (i + 1.) ** beta) for i in range(1, 99)]);" |
666 | 666 | ], |
667 | 667 | "language": "python", |
668 | 668 | "metadata": {}, |
|
678 | 678 | "# map_.fit()\n", |
679 | 679 | "\n", |
680 | 680 | "mcmc = pm.MCMC(model)\n", |
681 | | - "mcmc.sample(50000, 40000)\n" |
| 681 | + "mcmc.sample(50000, 40000);" |
682 | 682 | ], |
683 | 683 | "language": "python", |
684 | 684 | "metadata": {}, |
|
706 | 706 | "collapsed": false, |
707 | 707 | "input": [ |
708 | 708 | "from pymc.Matplot import plot as mcplot\n", |
709 | | - "mcplot(mcmc)\n" |
| 709 | + "mcplot(mcmc);" |
710 | 710 | ], |
711 | 711 | "language": "python", |
712 | 712 | "metadata": {}, |
|
729 | 729 | "cell_type": "code", |
730 | 730 | "collapsed": false, |
731 | 731 | "input": [ |
732 | | - "stars_to_explore[1:]\n" |
| 732 | + "stars_to_explore[1:];" |
733 | 733 | ], |
734 | 734 | "language": "python", |
735 | 735 | "metadata": {}, |
|
749 | 749 | "cell_type": "code", |
750 | 750 | "collapsed": false, |
751 | 751 | "input": [ |
752 | | - "a = stats.pareto.rvs(2.5, size=(50000, 1))\n" |
| 752 | + "a = stats.pareto.rvs(2.5, size=(50000, 1));" |
753 | 753 | ], |
754 | 754 | "language": "python", |
755 | 755 | "metadata": {}, |
|
761 | 761 | "collapsed": false, |
762 | 762 | "input": [ |
763 | 763 | "hist(a, bins=100)\n", |
764 | | - "print\n" |
| 764 | + "print;" |
765 | 765 | ], |
766 | 766 | "language": "python", |
767 | 767 | "metadata": {}, |
|
784 | 784 | "cell_type": "code", |
785 | 785 | "collapsed": false, |
786 | 786 | "input": [ |
787 | | - "y = [(a >= i).sum() for i in range(1, 100)]\n" |
| 787 | + "y = [(a >= i).sum() for i in range(1, 100)];" |
788 | 788 | ], |
789 | 789 | "language": "python", |
790 | 790 | "metadata": {}, |
|
798 | 798 | "y_ = -np.diff(y)\n", |
799 | 799 | "print y_\n", |
800 | 800 | "\n", |
801 | | - "print y\n" |
| 801 | + "print y;" |
802 | 802 | ], |
803 | 803 | "language": "python", |
804 | 804 | "metadata": {}, |
|
826 | 826 | "cell_type": "code", |
827 | 827 | "collapsed": false, |
828 | 828 | "input": [ |
829 | | - "b = -2.3\n" |
| 829 | + "b = -2.3;" |
830 | 830 | ], |
831 | 831 | "language": "python", |
832 | 832 | "metadata": {}, |
|
837 | 837 | "cell_type": "code", |
838 | 838 | "collapsed": false, |
839 | 839 | "input": [ |
840 | | - "np.sum([y_[i - 1] * np.log((i + 0.) ** b - (i + 1.) ** b) for i in range(1, 7)]) + y[-1] * np.log(7)\n" |
| 840 | + "np.sum([y_[i - 1] * np.log((i + 0.) ** b - (i + 1.) ** b) for i in range(1, 7)]) + y[-1] * np.log(7);" |
841 | 841 | ], |
842 | 842 | "language": "python", |
843 | 843 | "metadata": {}, |
|
856 | 856 | "cell_type": "code", |
857 | 857 | "collapsed": false, |
858 | 858 | "input": [ |
859 | | - "y_\n" |
| 859 | + "y_;" |
860 | 860 | ], |
861 | 861 | "language": "python", |
862 | 862 | "metadata": {}, |
|
875 | 875 | "cell_type": "code", |
876 | 876 | "collapsed": false, |
877 | 877 | "input": [ |
878 | | - "np.append(y_, y[-1])\n" |
| 878 | + "np.append(y_, y[-1]);" |
879 | 879 | ], |
880 | 880 | "language": "python", |
881 | 881 | "metadata": {}, |
|
894 | 894 | "cell_type": "code", |
895 | 895 | "collapsed": false, |
896 | 896 | "input": [ |
897 | | - "mc.Uninformative?\n" |
| 897 | + "mc.Uninformative?" |
898 | 898 | ], |
899 | 899 | "language": "python", |
900 | 900 | "metadata": {}, |
|
0 commit comments