Update 03-Gaussians.ipynb

Fix minor typos.
This commit is contained in:
Willie Maddox 2019-01-02 13:40:05 -06:00 committed by GitHub
parent e84f801836
commit 97a5e489a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -375,7 +375,7 @@
"\n",
"$$f(x) = \\frac{1}{b - a}$$\n",
"\n",
"compute the expected value for $a=0$ and $B=20$.\n",
"compute the expected value for $a=0$ and $b=20$.\n",
"\n",
"### Solution\n",
"$$\\begin{aligned}\n",
@ -1011,9 +1011,9 @@
"\n",
"$$M = \\iiint_R p(x,y,z)\\, dV$$\n",
"\n",
"We do the same with *probability density*. If you want to know the temperature being between 20°C and 21°C kph you would integrate the curve above from 20 to 21. As you know the integral of a curve gives you the area under the curve. Since this is a curve of the probability density, the integral of the density is the probability. \n",
"We do the same with *probability density*. If you want to know the temperature being between 20°C and 21°C you would integrate the curve above from 20 to 21. As you know the integral of a curve gives you the area under the curve. Since this is a curve of the probability density, the integral of the density is the probability. \n",
"\n",
"What is the probability of a the temperature being exactly 22°C? Intuitively, 0. These are real numbers, and the odds of 22°C vs, say, 22.00000000000017°C is infinitesimal. Mathematically, what would we get if we integrate from 22 to 22? Zero. \n",
"What is the probability of the temperature being exactly 22°C? Intuitively, 0. These are real numbers, and the odds of 22°C vs, say, 22.00000000000017°C is infinitesimal. Mathematically, what would we get if we integrate from 22 to 22? Zero. \n",
"\n",
"Thinking back to the rock, what is the weight of an single point on the rock? An infinitesimal point must have no weight. It makes no sense to ask the weight of a single point, and it makes no sense to ask about the probability of a continuous distribution having a single value. The answer for both is obviously zero.\n",
"\n",
@ -1062,7 +1062,7 @@
"\n",
"$$\\text{temp} \\sim \\mathcal{N}(22,4)$$\n",
"\n",
"This is an extremely important result. Gaussians allow me to capture an infinite number of possible values with only two numbers! With the values $\\mu=22$ and $\\sigma^2=4$ I can compute the distribution of measurements for over any range.\n",
"This is an extremely important result. Gaussians allow me to capture an infinite number of possible values with only two numbers! With the values $\\mu=22$ and $\\sigma^2=4$ I can compute the distribution of measurements over any range.\n",
"\n",
"Some sources use $\\mathcal N (\\mu, \\sigma)$ instead of $\\mathcal N (\\mu, \\sigma^2)$. Either is fine, they are both conventions. You need to keep in mind which form is being used if you see a term such as $\\mathcal{N}(22,4)$. In this book I always use $\\mathcal N (\\mu, \\sigma^2)$, so $\\sigma=2$, $\\sigma^2=4$ for this example."
]
@ -1393,7 +1393,7 @@
"source": [
"## Putting it all Together\n",
"\n",
"Now we are ready to talk about Gaussians can be used in filtering. In the next chapter we will implement a filter using Gaussins. Here I will explain why we would want to use Gaussians.\n",
"Now we are ready to talk about how Gaussians can be used in filtering. In the next chapter we will implement a filter using Gaussins. Here I will explain why we would want to use Gaussians.\n",
"\n",
"In the previous chapter we represented probability distributions with an array. We performed the update computation by computing the element-wise product of that distribution with another distribution representing the likelihood of the measurement at each point, like so:"
]
@ -1529,13 +1529,13 @@
"\n",
"$$p(A \\mid B) = \\frac{p(B \\mid A)\\, p(A)}{p(B)}$$\n",
"\n",
"In the equation above $B$ is the *evidence*, $p(A)$ is the *prior*, $p(B \\mid A)$ is the *likelihood*, and $p(A \\mid B)$ is the *posterior*. By substituting the mathematical terms with the corresponding words you can see that Bayes theorem matches out update equation. Let's rewrite the equation in terms of our problem. We will use $x_i$ for the position at *i*, and $z$ for the measurement. Hence, we want to know $P(x_i \\mid z)$, that is, the probability of the dog being at $x_i$ given the measurement $z$. \n",
"In the equation above $B$ is the *evidence*, $p(A)$ is the *prior*, $p(B \\mid A)$ is the *likelihood*, and $p(A \\mid B)$ is the *posterior*. By substituting the mathematical terms with the corresponding words you can see that Bayes theorem matches our update equation. Let's rewrite the equation in terms of our problem. We will use $x_i$ for the position at *i*, and $z$ for the measurement. Hence, we want to know $P(x_i \\mid z)$, that is, the probability of the dog being at $x_i$ given the measurement $z$. \n",
"\n",
"So, let's plug that into the equation and solve it.\n",
"\n",
"$$p(x_i \\mid z) = \\frac{p(z \\mid x_i) p(x_i)}{p(z)}$$\n",
"\n",
"That looks ugly, but it is actually quite simple. Let's figure out what each term on the right means. First is $p(z \\mid x_i)$. This is the the likelihood, or the probability for the measurement at every cell $x_i$. $p(x_i)$ is the *prior* - our belief before incorporating the measurements. We multiply those together. This is just the unnormalized multiplication in the `update()` function:\n",
"That looks ugly, but it is actually quite simple. Let's figure out what each term on the right means. First is $p(z \\mid x_i)$. This is the likelihood, or the probability for the measurement at every cell $x_i$. $p(x_i)$ is the *prior* - our belief before incorporating the measurements. We multiply those together. This is just the unnormalized multiplication in the `update()` function:\n",
"\n",
"```python\n",
"def update(likelihood, prior):\n",
@ -1822,7 +1822,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"That looks like I would expect. The signal is centered around 10. A standard deviation of 2 means that 68% of the measurements will be within $\\pm$ 2 of 10, and 99% will be within $\\pm$ 6 of 10, and that looks like what is happening. \n",
"That looks like what I would expect. The signal is centered around 10. A standard deviation of 2 means that 68% of the measurements will be within $\\pm$ 2 of 10, and 99% will be within $\\pm$ 6 of 10, and that looks like what is happening. \n",
"\n",
"Now let's look at distribution generated with the Student's $t$-distribution. I will not go into the math, but just give you the source code for it and then plot a distribution using it."
]