|
17 | 17 | "========\n", |
18 | 18 | "\n", |
19 | 19 | "#####Version 0.1\n", |
20 | | - "Welcome to *Bayesian Methods for Hackers*. The full Github repository, and additional chapters, is available at [github/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers](https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers). We hope you enjoy!" |
| 20 | + "Welcome to *Bayesian Methods for Hackers*. The full Github repository, and additional chapters, is available at [github/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers](https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers). We hope you enjoy the book, and we encourage any contributions!" |
21 | 21 | ] |
22 | 22 | }, |
23 | 23 | { |
24 | 24 | "cell_type": "markdown", |
25 | 25 | "metadata": {}, |
26 | 26 | "source": [ |
27 | 27 | "Chapter 1\n", |
28 | | - "------\n", |
| 28 | + "======\n", |
29 | 29 | "***" |
30 | 30 | ] |
31 | 31 | }, |
|
151 | 151 | "source": [ |
152 | 152 | "##### Example: Mandatory coin-flip example\n", |
153 | 153 | "\n", |
154 | | - "Since every statistics text must contain a coin-flipping example, I'll use it here to get it out of the way. Suppose, naively, that you are unsure what the ratio of heads is in a coin flip (spoiler alert: it's 50%). You believe there is some true underlying ratio, call it $p$, but have no guess apriori. We begin to flip a coin, and record the observations: this is our data. How does our inference change as we observe more and more data? More specifically, what do our posterior probabilities look like?\n", |
| 154 | + "Every statistics text must contain a coin-flipping example, I'll use it here to get it out of the way. Suppose, naively, that you are unsure about the probability of heads in a coin flip (spoiler alert: it's 50%). You believe there is some true underlying ratio, call it $p$, but have no prior opinion on what $p$ might be. \n", |
| 155 | + "\n", |
| 156 | + "We begin to flip a coin, and record the observations: either $H$ or $T$. This is our observed data. An interesting question to ask is how our inference changes as we observe more and more data? More specifically, what do our posterior probabilities look like when we have little data, versus when we have lots of data. \n", |
155 | 157 | "\n", |
156 | | - "Below we plot a sequence of updating posteriors as we observe data (coin flips)." |
| 158 | + "Below we plot a sequence of updating posterior probabilities as we observe increasing amounts of data (coin flips)." |
157 | 159 | ] |
158 | 160 | }, |
159 | 161 | { |
|
231 | 233 | "cell_type": "markdown", |
232 | 234 | "metadata": {}, |
233 | 235 | "source": [ |
234 | | - "As the plot above shows, as we start to observe data, our posterior probabilities, represented as the above curves, start to shift and move around. Eventually, as we observe more and more data, our probabilities will lump closer and closer around the true value of $p=0.5$ (marked by a dashed line). \n", |
| 236 | + "The posterior probabilities are represented by the curves, and our confidence is proportional to the height of the curve. As the plot above shows, as we start to observe data our posterior probabilities start to shift and move around. Eventually, as we observe more and more data (coin-flips), our probabilities will lump closer and closer around the true value of $p=0.5$ (marked by a dashed line). \n", |
235 | 237 | "\n", |
236 | | - "Notice that the graph is not always *peaked* at 0.5. Apriori, there is no reason it should be. Remember we do not know what $p$ is, we only have seen the data. In fact, if we observe quite extreme data, say 8 flips and only 1 observed heads, our distribution would look very biased *away* from lumping around 0.5.\n", |
| 238 | + "Notice that the plots are not always *peaked* at 0.5. There is no reason it should be: recall we assumed we did not have a prior opinion of what $p$ is. In fact, if we observe quite extreme data, say 8 flips and only 1 observed heads, our distribution would look very biased *away* from lumping around 0.5. As more data accumulates, we would see more and more probabilitiy being assigned at $p=0.5$.\n", |
237 | 239 | "\n", |
238 | | - "That being said, it does assign a positive probability to $p$ really being 0.5. As more data accumulates, we would see more and more probabilitiy being assigned at $p=0.5$.\n", |
239 | | - "\n", |
240 | | - "The next example is a simple demonstration of the mathematics of Bayesian updating. " |
| 240 | + "The next example is a simple demonstration of the mathematics of Bayesian inference. " |
241 | 241 | ] |
242 | 242 | }, |
243 | 243 | { |
|
368 | 368 | "##Probability Distributions\n", |
369 | 369 | "\n", |
370 | 370 | "\n", |
371 | | - "**Let's quickly recall what a probability distribution is:** Let $Z$ be some random variable. Then associated with $Z$ is a *probability distribution function* that assigns probabilities to the different outcomes $Z$ can take. There are three cases:\n", |
| 371 | + "**Let's quickly recall what a probability distribution is:** Let $Z$ be some random variable. Then associated with $Z$ is a *probability distribution function* that assigns probabilities to the different outcomes $Z$ can take. Graphically, a probability distribution is a curve where the probability of an outcome is proportional to the height of the curve. You can see examples in the first figure of this chapter. \n", |
| 372 | + "\n", |
| 373 | + "We can divide random variables into three classifications:\n", |
372 | 374 | "\n", |
373 | 375 | "- **$Z$ is discrete**: Discrete random variables may only assume values on a specified list. Things like populations, movie ratings, and number of votes are all discrete random variables. Discrete random variables become more clear when we contrast them with...\n", |
374 | 376 | "\n", |
|
692 | 694 | "input": [ |
693 | 695 | "### Myserious code to be explained later.\n", |
694 | 696 | "mcmc = mc.MCMC(model)\n", |
695 | | - "mcmc.sample( 20000, 5000, 1 )" |
| 697 | + "mcmc.sample( 25000, 5000, 1 )" |
696 | 698 | ], |
697 | 699 | "language": "python", |
698 | 700 | "metadata": {}, |
|
0 commit comments