Adjusted to use upper case x for filter state.

This commit is contained in:
Roger Labbe 2014-11-08 20:59:53 -08:00
parent c28582aa71
commit 9262b2796f
12 changed files with 336 additions and 531 deletions

View File

@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
"signature": "sha256:77fc7fd84343d91f4f546e53400a6fc405edc78def2867c025f1ab848bc94662"
"signature": "sha256:ccf1289e0126a8e295c808727490b0379358aa10f7b39bee76c2752b020a4d54"
},
"nbformat": 3,
"nbformat_minor": 0,
@ -43,6 +43,8 @@
"html": [
"<style>\n",
"@import url('http://fonts.googleapis.com/css?family=Source+Code+Pro');\n",
"@import url('http://fonts.googleapis.com/css?family=Vollkorn');\n",
"@import url('http://fonts.googleapis.com/css?family=Arimo');\n",
"\n",
" div.cell{\n",
" width: 850px;\n",
@ -129,9 +131,9 @@
" white-space: nowrap;\n",
" }\n",
" div.text_cell_render{\n",
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
" font-family: 'Arimo',verdana,arial,sans-serif;\n",
" line-height: 135%;\n",
" font-size: 110%;\n",
" font-size: 125%;\n",
" width:750px;\n",
" margin-left:auto;\n",
" margin-right:auto;\n",
@ -141,12 +143,12 @@
" div.output_subarea.output_text.output_pyout {\n",
" overflow-x: auto;\n",
" overflow-y: scroll;\n",
" max-height: 300px;\n",
" max-height: 50000px;\n",
" }\n",
" div.output_subarea.output_stream.output_stdout.output_text {\n",
" overflow-x: auto;\n",
" overflow-y: scroll;\n",
" max-height: 300px;\n",
" max-height: 50000px;\n",
" }\n",
" code{\n",
" font-size: 70%;\n",
@ -257,13 +259,13 @@
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 1,
"prompt_number": 4,
"text": [
"<IPython.core.display.HTML at 0x7f61100629e8>"
"<IPython.core.display.HTML at 0x7f72b8c41518>"
]
}
],
"prompt_number": 1
"prompt_number": 4
},
{
"cell_type": "heading",

View File

@ -275,7 +275,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now that we understand the histogram filter and Gaussians we are prepared to implement a 1D Kalman filter. We will do this exactly as we did the histogram filter - rather than going into the theory we will just develop the code step by step. But first, let's set the book style."
"Now that we understand the histogram filter and Gaussians we are prepared to implement a 1D Kalman filter. We will do this exactly as we did the histogram filter - rather than going into the theory we will just develop the code step by step."
]
},
{
@ -2331,25 +2331,6 @@
"\n",
"If you understand this, you will be able to understand multidimensional Kalman filters and the various extensions that have been make on them. If you do not fully understand this, I strongly suggest rereading this chapter. Try implementing the filter from scratch, just by looking at the equations and reading the text. Change the constants. Maybe try to implement a different tracking problem, like tracking stock prices. Experimentation will build your intuition and understanding of how these marvelous filters work."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 33
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**author notes**:\n",
" clean up the code - same stuff duplicated over and over - write a 'clean implementation' at the end.\n",
" \n",
" "
]
}
],
"metadata": {}

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 KiB

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 481 KiB

After

Width:  |  Height:  |  Size: 465 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -363,7 +363,7 @@
"\n",
"$$\\mathbf{v}=\\dot{\\mathbf{x}}$$\n",
"\n",
"where $\\dot{\\mathbf{x}}$ is the notation for the derivative of $\\mathbf{x}$, or $\\frac{d \\mathbf{x}}{d t}$.\n",
"where $\\dot{\\mathbf{x}}$ is the notation for the derivative of $\\mathbf{x}$ with respect to t, or $\\frac{d \\mathbf{x}}{d t}$.\n",
"\n",
"In general terms we can then say that a dynamic system consists of equations of the form\n",
"\n",
@ -441,7 +441,7 @@
"\n",
"$$ \\Phi(t) = e^{\\mathbf{F}t} = \\mathbf{I} + \\mathbf{F}t + \\frac{(\\mathbf{F}t)^2}{2!} + \\frac{(\\mathbf{F}t)^3}{3!} + ... $$\n",
"\n",
"This is much easier to compute, and is the typical approach used in Kalman filter design when the filter is reasonably small. If you are wondering where $e$ came from, I again point to wikipedia - this time the matrix exponential article [2]. Here the important point is to recognize the very simple and regular form this equation takes.\n",
"This is much easier to compute, and is the typical approach used in Kalman filter design when the filter is reasonably small. If you are wondering where $e$ came from, I again point to wikipedia - this time the matrix exponential article [2]. Here the important point is to recognize the very simple and regular form this equation takes. We will put this form into use in the next chapter, so I will not belabor its use here. \n",
"\n",
"Finally, there are numerical techniques to find $\\Phi$. As filters get larger finding analytical solutions becomes very tedious (though packages like Sympy make it easier). C. F. van Loan [3] has developed a technique that finds both $\\Phi$ and $Q$ numerically.\n",
"\n",
@ -489,7 +489,7 @@
"I will start with the update step, as that is what we started with in the one dimensional Kalman filter case. Our first equation is\n",
"\n",
"$$\n",
"\\mathbf{\\gamma} = \\mathbf{z} - \\mathbf{H x}\\tag{3}\n",
"\\mathbf{y} = \\mathbf{z} - \\mathbf{H x}\\tag{3}\n",
"$$\n",
"\n",
"On the right we have $\\mathbf{Hx}$. That should be recognizable as the measurement function. Multiplying $\\mathbf{H}$ with $\\mathbf{x}$ puts $\\mathbf{x}$ into *measurement space*; in other words, the same basis and units as the sensor's measurements. The variable $\\mathbf{z}$ is just the measurement; it is typical, but not universal to use $\\mathbf{z}$ to denote measurements in the literature ($\\mathbf{y}$ is also sometimes used). Do you remember this chart?"
@ -520,7 +520,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The blue point labeled \"prediction\" is the output of $\\mathbf{Hx}$, and the dot labeled \"measurement\" is $\\mathbf{z}$. Therefore, $\\gamma = \\mathbf{z} - \\mathbf{Hx}$ is how we compute the residual, drawn in red, where $\\gamma$ is the residual.\n",
"The blue point labeled \"prediction\" is the output of $\\mathbf{Hx}$, and the dot labeled \"measurement\" is $\\mathbf{z}$. Therefore, $\\mathbf{y} = \\mathbf{z} - \\mathbf{Hx}$ is how we compute the residual, drawn in red, where $\\mathbf{z}$ is the residual.\n",
"\n",
"The next two lines are the formidable:\n",
"\n",
@ -587,7 +587,7 @@
"metadata": {},
"source": [
"Our next line is:\n",
" $$\\mathbf{x}=\\mathbf{x}' +\\mathbf{K\\gamma}\\tag{5}$$\n",
" $$\\mathbf{x}=\\mathbf{x}' +\\mathbf{Ky}\\tag{5}$$\n",
"\n",
"This just multiplies the residual by the Kalman gain, and adds it to the state variable. In other words, this is the computation of our new estimate.\n",
"\n",

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
"signature": "sha256:19938ddfba204e20c435b33acc3d723467354126675c5aa78dc8200036994fad"
"signature": "sha256:f9b7acba67bef2276a493d93976a5cf0997cb86a8644ecb6817597f4a3759b01"
},
"nbformat": 3,
"nbformat_minor": 0,
@ -43,6 +43,8 @@
"html": [
"<style>\n",
"@import url('http://fonts.googleapis.com/css?family=Source+Code+Pro');\n",
"@import url('http://fonts.googleapis.com/css?family=Vollkorn');\n",
"@import url('http://fonts.googleapis.com/css?family=Arimo');\n",
"\n",
" div.cell{\n",
" width: 850px;\n",
@ -129,9 +131,9 @@
" white-space: nowrap;\n",
" }\n",
" div.text_cell_render{\n",
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
" font-family: 'Arimo',verdana,arial,sans-serif;\n",
" line-height: 135%;\n",
" font-size: 110%;\n",
" font-size: 125%;\n",
" width:750px;\n",
" margin-left:auto;\n",
" margin-right:auto;\n",
@ -141,12 +143,12 @@
" div.output_subarea.output_text.output_pyout {\n",
" overflow-x: auto;\n",
" overflow-y: scroll;\n",
" max-height: 300px;\n",
" max-height: 50000px;\n",
" }\n",
" div.output_subarea.output_stream.output_stdout.output_text {\n",
" overflow-x: auto;\n",
" overflow-y: scroll;\n",
" max-height: 300px;\n",
" max-height: 50000px;\n",
" }\n",
" code{\n",
" font-size: 70%;\n",
@ -259,7 +261,7 @@
"output_type": "pyout",
"prompt_number": 1,
"text": [
"<IPython.core.display.HTML at 0x7fb1b0f91a20>"
"<IPython.core.display.HTML at 0x7fa5b3193048>"
]
}
],

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long