|  | 
| 723 | 723 |       "# sample N Bernoulli random variables from Ber(0.05).\n", | 
| 724 | 724 |       "# each random variable has a 0.05 chance of being a 1.\n", | 
| 725 | 725 |       "# this is the data-generation step\n", | 
| 726 |  | -      "occurances = mc.rbernoulli(p_true, N)\n", | 
|  | 726 | +      "occurrences = mc.rbernoulli(p_true, N)\n", | 
| 727 | 727 |       "\n", | 
| 728 |  | -      "print occurances  # Remember: Python treats True == 1, and False == 0\n", | 
| 729 |  | -      "print occurances.sum()" | 
|  | 728 | +      "print occurrences  # Remember: Python treats True == 1, and False == 0\n", | 
|  | 729 | +      "print occurrences.sum()" | 
| 730 | 730 |      ], | 
| 731 | 731 |      "language": "python", | 
| 732 | 732 |      "metadata": {}, | 
|  | 
| 753 | 753 |      "cell_type": "code", | 
| 754 | 754 |      "collapsed": false, | 
| 755 | 755 |      "input": [ | 
| 756 |  | -      "# Occurances.mean is equal to n/N.\n", | 
| 757 |  | -      "print \"What is the observed frequency in Group A? %.4f\" % occurances.mean()\n", | 
| 758 |  | -      "print \"Does this equal the true frequency? %s\" % (occurances.mean() == p_true)" | 
|  | 756 | +      "# Occurrences.mean is equal to n/N.\n", | 
|  | 757 | +      "print \"What is the observed frequency in Group A? %.4f\" % occurrences.mean()\n", | 
|  | 758 | +      "print \"Does this equal the true frequency? %s\" % (occurrences.mean() == p_true)" | 
| 759 | 759 |      ], | 
| 760 | 760 |      "language": "python", | 
| 761 | 761 |      "metadata": {}, | 
|  | 
| 783 | 783 |      "collapsed": false, | 
| 784 | 784 |      "input": [ | 
| 785 | 785 |       "#include the observations, which are Bernoulli\n", | 
| 786 |  | -      "obs = mc.Bernoulli(\"obs\", p, value=occurances, observed=True)\n", | 
|  | 786 | +      "obs = mc.Bernoulli(\"obs\", p, value=occurrences, observed=True)\n", | 
| 787 | 787 |       "\n", | 
| 788 | 788 |       "#To be explained in chapter 3\n", | 
| 789 | 789 |       "mcmc = mc.MCMC([p, obs])\n", | 
|  | 
| 2111 | 2111 |       "plt.xlim(0.995, 1)\n", | 
| 2112 | 2112 |       "plt.hist(prob_31, bins=1000, normed=True, histtype='stepfilled')\n", | 
| 2113 | 2113 |       "plt.title(\"Posterior distribution of probability of defect, given $t = 31$\")\n", | 
| 2114 |  | -      "plt.xlabel(\"probability of defect occuring in O-ring\")\n" | 
|  | 2114 | +      "plt.xlabel(\"probability of defect occurring in O-ring\")\n" | 
| 2115 | 2115 |      ], | 
| 2116 | 2116 |      "language": "python", | 
| 2117 | 2117 |      "metadata": {}, | 
|  | 
0 commit comments