Merge pull request #64 from Qgel/master
Fixed minor errors in Chapter 6,7,9,9,10
This commit is contained in:
commit
ded747ec6a
@ -1431,7 +1431,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"In the previous chapter we filtered very noisy signals with much simpler code than the code above. However, realize that right now we are working with a very simple example - an object moving through 1-D space and one sensor. That is about the limit of what we can compute with the code in the last chapter. In contrast, we can implement very complicated, multidimensional filter with this code merely by altering are assignments to the filter's variables. Perhaps we want to track 100 dimensions in financial models. Or we have an aircraft with a GPS, INS, TACAN, radar altimeter, baro altimeter, and airspeed indicator, and we want to integrate all those sensors into a model that predicts position, velocity, and accelerations in 3D (which requires 9 state variables). We can do that with the code in this chapter."
|
||||
"In the previous chapter we filtered very noisy signals with much simpler code than the code above. However, realize that right now we are working with a very simple example - an object moving through 1-D space and one sensor. That is about the limit of what we can compute with the code in the last chapter. In contrast, we can implement very complicated, multidimensional filter with this code merely by altering our assignments to the filter's variables. Perhaps we want to track 100 dimensions in financial models. Or we have an aircraft with a GPS, INS, TACAN, radar altimeter, baro altimeter, and airspeed indicator, and we want to integrate all those sensors into a model that predicts position, velocity, and accelerations in 3D (which requires 9 state variables). We can do that with the code in this chapter."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -650,7 +650,7 @@
|
||||
"\\end{aligned}\n",
|
||||
"$$\n",
|
||||
"\n",
|
||||
"The state $\\mathbf{x}$ only has one variable, so it is a $1\\times 1$ matrix. Our motion $\\mathbf{u}$ is also be a $1\\times 1$ matrix. Therefore, $\\mathbf{F}$ and $\\mathbf{B}$ must also be $1\\times 1$ matrices. That means that they are all scalars, and we can write\n",
|
||||
"The state $\\mathbf{x}$ only has one variable, so it is a $1\\times 1$ matrix. Our motion $\\mathbf{u}$ is also a $1\\times 1$ matrix. Therefore, $\\mathbf{F}$ and $\\mathbf{B}$ must also be $1\\times 1$ matrices. That means that they are all scalars, and we can write\n",
|
||||
"\n",
|
||||
"$$x = Fx + Bu$$\n",
|
||||
"\n",
|
||||
@ -687,7 +687,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Here our our multivariate Kalman filter equations for the update step.\n",
|
||||
"Here our multivariate Kalman filter equations for the update step.\n",
|
||||
"\n",
|
||||
"$$\n",
|
||||
"\\begin{aligned}\n",
|
||||
@ -1351,7 +1351,7 @@
|
||||
"\n",
|
||||
"where $\\Gamma$ is the *noise gain* of the system, and $w$ is the constant piecewise acceleration (or velocity, or jerk, etc). \n",
|
||||
"\n",
|
||||
"Lets start with by looking a first order system. In this case we have the state transition function\n",
|
||||
"Lets start by looking at a first order system. In this case we have the state transition function\n",
|
||||
"\n",
|
||||
"$$\\mathbf{F} = \\begin{bmatrix}1&\\Delta t \\\\ 0& 1\\end{bmatrix}$$\n",
|
||||
"\n",
|
||||
|
@ -942,7 +942,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We have only studied tracking position and velocity. It has worked well, but only because I have been selecting problems for which this is an appropriate choice. You know have enough experience with the Kalman filter to consider this in more general terms.\n",
|
||||
"We have only studied tracking position and velocity. It has worked well, but only because I have been selecting problems for which this is an appropriate choice. You now have enough experience with the Kalman filter to consider this in more general terms.\n",
|
||||
"\n",
|
||||
"What do I mean by **order**? In the context of these system models it is the number of derivatives required to accurately model a system. Consider a system that does not change, such as the height of a building. There is no change, so there is no need for a derivative, and the order of the system is zero. We could express this in an equation as $x = 312.5$.\n",
|
||||
"\n",
|
||||
@ -2012,7 +2012,7 @@
|
||||
"\n",
|
||||
"$$\\epsilon = \\frac{x^2}{P}$$\n",
|
||||
"\n",
|
||||
"If this is not clear, recall that the transpose of a scalar is the same scalar, and the $a^{-1} =\\frac{1}{a}$ for a scalar.\n",
|
||||
"If this is not clear, recall that the transpose of a scalar is the same scalar, and that $a^{-1} =\\frac{1}{a}$ for a scalar.\n",
|
||||
"\n",
|
||||
"So as the covariance matrix gets smaller NEES gets larger for the same error. The covariance matrix is the filter's estimate of it's error, so if it is small relative to the estimation error then it is performing worse than if it is large relative to the same estimation error.\n",
|
||||
"\n",
|
||||
@ -2082,7 +2082,7 @@
|
||||
"```python\n",
|
||||
"from filterpy.stats import NESS\n",
|
||||
"```\n",
|
||||
"This is the best measure of the filter's performance, and should be used whenever possible. If you simulation is of limited fidelity then you need to use another approach.\n",
|
||||
"This is the best measure of the filter's performance, and should be used whenever possible. If your simulation is of limited fidelity then you need to use another approach.\n",
|
||||
"\n",
|
||||
"### Likelihood Function\n",
|
||||
"\n",
|
||||
@ -3174,7 +3174,7 @@
|
||||
"traj = BallTrajectory2D(x0=0, y0=15, velocity=100, theta_deg=60)\n",
|
||||
"```\n",
|
||||
" \n",
|
||||
"and then call `traj.position(t)` for each time step. Let's test this "
|
||||
"and then call `traj.step(t)` for each time step. Let's test this "
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -3286,7 +3286,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Our next step is to design the state transition function. Recall that the state transistion function is implemented as a matrix $\\mathbf{F}$ that we multiply with the previous state of our system to get the next state$\\mathbf{x}' = \\mathbf{Fx}$.\n",
|
||||
"Our next step is to design the state transition function. Recall that the state transistion function is implemented as a matrix $\\mathbf{F}$ that we multiply with the previous state of our system to get the next state $\\mathbf{x}' = \\mathbf{Fx}$.\n",
|
||||
"\n",
|
||||
"I will not belabor this as it is very similar to the 1-D case we did in the previous chapter. Our state equations for position and velocity would be:\n",
|
||||
"\n",
|
||||
@ -3323,7 +3323,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We will use the control input to account for the force of gravity. The term $\\mathbf{Bu}$ is added to $\\mathbf{x^-}$ to account for how much $\\mathbf{x^-}$ changes due to gravity. We can say that $\\mathbf{Bu}$ contains $\\begin{bmatrix}\\Delta x_g & \\Delta \\dot{x_g} & \\Delta y_g & \\Delta \\dot{y_g}\\end{bmatrix}^\\mathsf{T}$.\n",
|
||||
"We will use the control input to account for the force of gravity. The term $\\mathbf{Bu}$ is added to $\\mathbf{\bar{x}}$ to account for how much $\\mathbf{\bar{x}}$ changes due to gravity. We can say that $\\mathbf{Bu}$ contains $\\begin{bmatrix}\\Delta x_g & \\Delta \\dot{x_g} & \\Delta y_g & \\Delta \\dot{y_g}\\end{bmatrix}^\\mathsf{T}$.\n",
|
||||
"\n",
|
||||
"If we look at the discretized equations we see that gravity only affect the velocity for $y$.\n",
|
||||
"\n",
|
||||
|
@ -320,7 +320,7 @@
|
||||
"source": [
|
||||
"As asserted in the introduction the only math you really know how to do is linear math. Equations of the form \n",
|
||||
"\n",
|
||||
"$$ A\\mathbf{x}=\\mathbf{b}$$.\n",
|
||||
"$$ A\\mathbf{x}=\\mathbf{b}$$\n",
|
||||
"\n",
|
||||
"That may strike you as hyperbole. After all, in this book we have integrated a polynomial to get distance from velocity and time. We know how to integrate a polynomial, for example, and so we are able to find the closed form equation for distance given velocity and time:\n",
|
||||
"\n",
|
||||
@ -494,7 +494,7 @@
|
||||
"Supporting_Notebooks folder. You can also read it online [here](https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/blob/master/Supporting_Notebooks/Computing_and_plotting_PDFs.ipynb)[1]\n",
|
||||
"\n",
|
||||
"The plot labeled 'input' is the histogram of the original data. This is passed through the transfer function $f(x)=2x+1$ which is displayed in the chart on the bottom left\n",
|
||||
". The red lines shows how one value, $x=0$ is passed through the function. Each value from input is passed through in the same way to the output function on the left. For the output I computed the mean by taking the average of all the points, and drew the results with the dotted blue line. A solid blue line shows the actual mean for the point $x=0$. The output looks like a Gaussian, and is in fact a Gaussian. We can see that it is altered -the variance in the output is larger than the variance in the input, and the mean has been shifted from 0 to 1, which is what we would expect given the transfer function $f(x)=2x+1$ The $2x$ affects the variance, and the $+1$ shifts the mean The computed mean, represented by the dotted blue line, is nearly equal to the actual mean. If we used more points in our computation we could get arbitrarily close to the actual value.\n",
|
||||
". The red lines shows how one value, $x=0$ is passed through the function. Each value from input is passed through in the same way to the output function on the left. For the output I computed the mean by taking the average of all the points, and drew the results with the dotted blue line. A solid blue line shows the actual mean for the point $x=0$. The output looks like a Gaussian, and is in fact a Gaussian. We can see that the variance in the output is larger than the variance in the input, and the mean has been shifted from 0 to 1, which is what we would expect given the transfer function $f(x)=2x+1$ The $2x$ affects the variance, and the $+1$ shifts the mean The computed mean, represented by the dotted blue line, is nearly equal to the actual mean. If we used more points in our computation we could get arbitrarily close to the actual value.\n",
|
||||
"\n",
|
||||
"Now let's look at a nonlinear function and see how it affects the probability distribution."
|
||||
]
|
||||
|
@ -944,7 +944,7 @@
|
||||
"\n",
|
||||
"To design a linear Kalman filter you need to design the $\\bf{x}$, $\\bf{F}$, $\\bf{H}$, $\\bf{R}$, and $\\bf{Q}$ matrices. We have done this many times already so let me present a design to you without a lot of comment. We want a constant velocity model, so we can define $\\bf{x}$ to be\n",
|
||||
"\n",
|
||||
"$$ \\mathbf{x} = \\begin{bmatrix}x & \\dot{x} & y & \\dot{y} \\end{bmatrix}^\\mathsf{T}$$.\n",
|
||||
"$$ \\mathbf{x} = \\begin{bmatrix}x & \\dot{x} & y & \\dot{y} \\end{bmatrix}^\\mathsf{T}$$\n",
|
||||
"\n",
|
||||
"With this ordering of state variables we can define our state transition model to be\n",
|
||||
"\n",
|
||||
|
Loading…
Reference in New Issue
Block a user