diff --git a/06_Multivariate_Kalman_filter/Multivariate_Kalman_Filters.ipynb b/06_Multivariate_Kalman_filter/Multivariate_Kalman_Filters.ipynb index 89e8951..6e1f0c1 100644 --- a/06_Multivariate_Kalman_filter/Multivariate_Kalman_Filters.ipynb +++ b/06_Multivariate_Kalman_filter/Multivariate_Kalman_Filters.ipynb @@ -1631,7 +1631,7 @@ " \n", "$\\mathbf{P}$ is dimensioned $n\\times n$, so $\\mathbf{Q}$ must have the same dimensions. We are just adding matrices, so hopefully it is clear that each element in $\\mathbf{Q}$ specifies how much uncertainty is added to the system due to the process noise. \n", "\n", - "We have not given the math for this yet, but if you suspect the math is simetimes difficult you would be correct. One of the problems is that we are usually modelling a *continuous* system - the behavior of the system is changing at every instant, but the Kalman filter is *discrete*. That means that we have to somehow convert the continuous noise of the system into a discrete value, which usually involves calculus. There are other difficulties I will not mention now." + "We have not given the math for this yet, but if you suspect the math is sometimes difficult you would be correct. One of the problems is that we are usually modelling a *continuous* system - the behavior of the system is changing at every instant, but the Kalman filter is *discrete*. That means that we have to somehow convert the continuous noise of the system into a discrete value, which usually involves calculus. There are other difficulties I will not mention now." ] }, { @@ -2022,7 +2022,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "There is still a lot to learn, but we have implemented our first, full Kalman filter using the same theory and equations as published by Nobert Kalman! Code very much like this runs inside of your GPS and phone, inside every airliner, inside of robots, and so on. \n", + "There is still a lot to learn, but we have implemented our first, full Kalman filter using the same theory and equations as published by Rudolf Kalman! Code very much like this runs inside of your GPS and phone, inside every airliner, inside of robots, and so on. \n", "\n", "The first plot plots the output of the Kalman filter against the measurements and the actual position of our dog (drawn in green). After the initial settling in period the filter should track the dog's position very closely. The yellow shaded portion between the black dotted lines shows 1 standard deviations of the filter's variance, which I explain in the next paragrah.\n", "\n", @@ -2219,7 +2219,7 @@ "\n", "As it turns out the Kalman filter equations are quite easy to deal with in one dimension, so let's do the mathematical proof. \n", "\n", - "> **Note:** This section will provide you with a strong intuition into what the Kalman filter equations are actually doing. While this section is not strictly required, I recommend reading this section carefully as it should make the restof the material easier to understand. It is not merely a proof of correctness that you would normally want to skip past! The equations look complicated, but they are actually doing something quite simple.\n", + "> **Note:** This section will provide you with a strong intuition into what the Kalman filter equations are actually doing. While this section is not strictly required, I recommend reading this section carefully as it should make the rest of the material easier to understand. It is not merely a proof of correctness that you would normally want to skip past! The equations look complicated, but they are actually doing something quite simple.\n", "\n", "Let'start with the predict step, which is slightly easier. Here are the multivariate equations. \n", "$$\n", @@ -2519,7 +2519,7 @@ "\n", "Let's remind ourselves of what the term *process uncertainty* means. Consider the problem of tracking a ball. We can accurately model its behavior in static air with math, but if there is any wind our model will diverge from reality. \n", "\n", - "In the first case we set `Q_var=10 m`, which is quite large. In physical terms this is telling the filter \"I don't trust my motion prediction step\" as we are saying that the variance in the velocity is 10. Strictly speaking, we are telling the filter there is a lot of external noise that we are not modeling with $\\small{\\mathbf{F}}$, but the upshot of that is to not trust the motion prediction step. So the filter will be computing velocity ($\\dot{x}$), but then mostly ignoring it because we are telling the filter that the computation is extremely suspect. Therefore the filter has nothing to use but the measurements, and thus it follows the measurements closely. \n", + "In the first case we set `Q_var=20 m`, which is quite large. In physical terms this is telling the filter \"I don't trust my motion prediction step\" as we are saying that the variance in the velocity is 10. Strictly speaking, we are telling the filter there is a lot of external noise that we are not modeling with $\\small{\\mathbf{F}}$, but the upshot of that is to not trust the motion prediction step. So the filter will be computing velocity ($\\dot{x}$), but then mostly ignoring it because we are telling the filter that the computation is extremely suspect. Therefore the filter has nothing to use but the measurements, and thus it follows the measurements closely. \n", "\n", "In the second case we set `Q_var=0.02 m`, which is quite small. In physical terms we are telling the filter \"trust the motion computation, it is really good!\". Again, more strictly this actually says there is very small amounts of process noise (variance 0.02 m), so the motion computation will be accurate. So the filter ends up ignoring some of the measurement as it jumps up and down, because the variation in the measurement does not match our trustworthy velocity prediction." ] diff --git a/10_Unscented_Kalman_Filters/Unscented_Kalman_Filter.ipynb b/10_Unscented_Kalman_Filters/Unscented_Kalman_Filter.ipynb index b589f30..7e9f52f 100644 --- a/10_Unscented_Kalman_Filters/Unscented_Kalman_Filter.ipynb +++ b/10_Unscented_Kalman_Filters/Unscented_Kalman_Filter.ipynb @@ -2536,6 +2536,17 @@ "The estimates are not perfect, but this is still a very difficult filtering problem. As the aircraft goes further downrange a very small measurement error can translate into a very large error in velocity and altitude. We are simulating a velocity of 100 and an altitude of 1000. The filter does not produce exactly these numbers, but it does quite well considering that the only measurement we are receiving is range to the aircraft. This is a classical problem that is presented while learning Kalman filters, and so I have presented it here. However, recognize that this is a very difficult problem for the filter because it is easy for us. If we ran this simulation for 50-100 seconds the filter would begin to diverge because the information in the measurement would be swamped by the noise in the signal." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Tracking a Circle\n", + "\n", + "Let's see how easy it is to deal with state equations which differ markedly, and nonlinearly, from the measurements. Let's assume that we are tracking an object travelling in a circle; perhaps a race car on a track. Our measurements give us coordinates in x,y, and we want to filter the car's position, heading, and speed on the race course. \n", + "\n", + "With a linear Kalman filter we don't have a lot of choice but to implement it as a constant acceleration model. $\\mathbf{H}$, the measurement matrix, must " + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/11_Ensemble_Kalman_Filter/Ensemble_Kalman_Filters.ipynb b/11_Ensemble_Kalman_Filter/Ensemble_Kalman_Filters.ipynb index 7936120..e69c586 100644 --- a/11_Ensemble_Kalman_Filter/Ensemble_Kalman_Filters.ipynb +++ b/11_Ensemble_Kalman_Filter/Ensemble_Kalman_Filters.ipynb @@ -271,7 +271,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "> I am not well versed with Ensemble filters. I have implemented one for this book, and made it work, but I have not used one in real life. Different sources use slightly different forms of these equations. If I implement the equations given in the sources the filter does not work. It is possible that I am doing something wrong. However, in various places on the web I have seen comments by people stating that they do the kinds of things I have done in my filter to make it work. In short, I do not understand this topic well, but choose to present my lack of knowledge rather than to gloss over the subject. I hope to master this topic in the future and to author a more definitive chapter. At the end of the chapter I document my current confusion and questions. In any case if I got confused by the sources perhaps you will to, so documenting my confusion can help you avoid the same.\n", + "> I am not well versed with Ensemble filters. I have implemented one for this book, and made it work, but I have not used one in real life. Different sources use slightly different forms of these equations. If I implement the equations given in the sources the filter does not work. It is possible that I am doing something wrong. However, in various places on the web I have seen comments by people stating that they do the kinds of things I have done in my filter to make it work. In short, I do not understand this topic well, but choose to present my lack of knowledge rather than to gloss over the subject. I hope to master this topic in the future and to author a more definitive chapter. At the end of the chapter I document my current confusion and questions. In any case if I got confused by the sources perhaps you also will, so documenting my confusion can help you avoid the same.\n", "\n", "\n", "The ensemble Kalman filter (EnKF) is very similar to the unscented Kalman filter (UKF) of the last chapter. If you recall, the UKF uses a set of deterministically chosen weighted sigma points passed through nonlinear state and measurement functions. After the sigma points are passed through the function, we find the mean and covariance of the points and use this as the filter's new mean and covariance. It is only an approximation of the true value, and thus suboptimal, but in practice the filter is highly accurate. It has the advantage of often producing more accurate estimates than the EKF does, and also does not require you to analytically derive the linearization of the state and measurement equations. \n",