Plots and text for g-h filter chapter.
Still needs work, but I am generally happy with the content.
This commit is contained in:
1 parent
234b331b45
commit
3b8654f70b
6 files changed
+1216
-911
No files matched your search
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:2b562cd882f0e19a9a7799763a6bf0d8986d23e7d0d648364928721d3c8a1026"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
"worksheets": [
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<center><h1>Kalman and Bayesian Filters in Python</h1></center>\n",
|
||||
"\n",
|
||||
"<p>\n",
|
||||
"<center><a href =\"http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/toc.ipynb\">Table of Contents</a></center>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": []
|
||||
}
|
||||
],
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
+10
-211
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:7495976b98b260c51070e71c79ee140a97a941fe3212c3dd523578ed269b756c"
|
||||
"signature": "sha256:2a1204bda534a6b1ff6da19b2380bade0615680eb021433a1b6d4332fb9281ea"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
@@ -14,226 +14,25 @@
|
||||
"input": [
|
||||
"#format the book\n",
|
||||
"import book_format\n",
|
||||
"book_format.load_style()"
|
||||
"book_format.load_style()\n",
|
||||
"\n",
|
||||
"%matplotlib inline\n",
|
||||
"import gh_internal\n",
|
||||
"gh_internal.create_predict_update_chart()\n"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"html": [
|
||||
"<style>\n",
|
||||
" div.cell{\n",
|
||||
" width: 850px;\n",
|
||||
" margin-left: 10% !important;\n",
|
||||
" margin-right: auto;\n",
|
||||
" }\n",
|
||||
" h1 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" }\n",
|
||||
" div.input_area {\n",
|
||||
" background: #F6F6F9;\n",
|
||||
" border: 1px solid #586e75;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .text_cell_render h1 {\n",
|
||||
" font-weight: 200;\n",
|
||||
" font-size: 40pt;\n",
|
||||
" line-height: 100%;\n",
|
||||
" color:#c76c0c;\n",
|
||||
" margin-bottom: 0em;\n",
|
||||
" margin-top: 0em;\n",
|
||||
" display: block;\n",
|
||||
" white-space: nowrap;\n",
|
||||
" } \n",
|
||||
" h2 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" text-indent:1em;\n",
|
||||
" }\n",
|
||||
" .text_cell_render h2 {\n",
|
||||
" font-weight: 200;\n",
|
||||
" font-size: 20pt;\n",
|
||||
" font-style: italic;\n",
|
||||
" line-height: 100%;\n",
|
||||
" color:#c76c0c;\n",
|
||||
" margin-bottom: 1.5em;\n",
|
||||
" margin-top: 0.5em;\n",
|
||||
" display: block;\n",
|
||||
" white-space: nowrap;\n",
|
||||
" } \n",
|
||||
" h3 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" }\n",
|
||||
" .text_cell_render h3 {\n",
|
||||
" font-weight: 300;\n",
|
||||
" font-size: 18pt;\n",
|
||||
" line-height: 100%;\n",
|
||||
" color:#d77c0c;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 2em;\n",
|
||||
" display: block;\n",
|
||||
" white-space: nowrap;\n",
|
||||
" }\n",
|
||||
" h4 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" }\n",
|
||||
" .text_cell_render h4 {\n",
|
||||
" font-weight: 300;\n",
|
||||
" font-size: 16pt;\n",
|
||||
" color:#d77c0c;\n",
|
||||
" margin-bottom: 0.5em;\n",
|
||||
" margin-top: 0.5em;\n",
|
||||
" display: block;\n",
|
||||
" white-space: nowrap;\n",
|
||||
" }\n",
|
||||
" h5 {\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" }\n",
|
||||
" .text_cell_render h5 {\n",
|
||||
" font-weight: 300;\n",
|
||||
" font-style: normal;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" font-size: 16pt;\n",
|
||||
" margin-bottom: 0em;\n",
|
||||
" margin-top: 1.5em;\n",
|
||||
" display: block;\n",
|
||||
" white-space: nowrap;\n",
|
||||
" }\n",
|
||||
" div.text_cell_render{\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" line-height: 135%;\n",
|
||||
" font-size: 125%;\n",
|
||||
" width:750px;\n",
|
||||
" margin-left:auto;\n",
|
||||
" margin-right:auto;\n",
|
||||
" text-align:justify;\n",
|
||||
" text-justify:inter-word;\n",
|
||||
" }\n",
|
||||
" div.output_subarea.output_text.output_pyout {\n",
|
||||
" overflow-x: auto;\n",
|
||||
" overflow-y: scroll;\n",
|
||||
" max-height: 300px;\n",
|
||||
" }\n",
|
||||
" div.output_subarea.output_stream.output_stdout.output_text {\n",
|
||||
" overflow-x: auto;\n",
|
||||
" overflow-y: scroll;\n",
|
||||
" max-height: 300px;\n",
|
||||
" }\n",
|
||||
" code{\n",
|
||||
" font-size: 78%;\n",
|
||||
" }\n",
|
||||
" .rendered_html code{\n",
|
||||
" background-color: transparent;\n",
|
||||
" }\n",
|
||||
" ul{\n",
|
||||
" margin: 2em;\n",
|
||||
" }\n",
|
||||
" ul li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.5em; \n",
|
||||
" }\n",
|
||||
" ul li li{\n",
|
||||
" padding-left: 0.2em; \n",
|
||||
" margin-bottom: 0.2em; \n",
|
||||
" margin-top: 0.2em; \n",
|
||||
" }\n",
|
||||
" ol{\n",
|
||||
" margin: 2em;\n",
|
||||
" }\n",
|
||||
" ol li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.5em; \n",
|
||||
" }\n",
|
||||
" ul li{\n",
|
||||
" padding-left: 0.5em; \n",
|
||||
" margin-bottom: 0.5em; \n",
|
||||
" margin-top: 0.2em; \n",
|
||||
" }\n",
|
||||
" a:link{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" a:visited{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" }\n",
|
||||
" a:hover{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color: #1d3b84;\n",
|
||||
" }\n",
|
||||
" a:focus{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" a:active{\n",
|
||||
" font-weight: bold;\n",
|
||||
" color:#447adb;\n",
|
||||
" }\n",
|
||||
" .rendered_html :link {\n",
|
||||
" text-decoration: none; \n",
|
||||
" }\n",
|
||||
" .rendered_html :hover {\n",
|
||||
" text-decoration: none; \n",
|
||||
" }\n",
|
||||
" .rendered_html :visited {\n",
|
||||
" text-decoration: none;\n",
|
||||
" }\n",
|
||||
" .rendered_html :focus {\n",
|
||||
" text-decoration: none;\n",
|
||||
" }\n",
|
||||
" .rendered_html :active {\n",
|
||||
" text-decoration: none;\n",
|
||||
" }\n",
|
||||
" .warning{\n",
|
||||
" color: rgb( 240, 20, 20 )\n",
|
||||
" } \n",
|
||||
" hr {\n",
|
||||
" color: #f3f3f3;\n",
|
||||
" background-color: #f3f3f3;\n",
|
||||
" height: 1px;\n",
|
||||
" }\n",
|
||||
" blockquote{\n",
|
||||
" display:block;\n",
|
||||
" background: #fcfcfc;\n",
|
||||
" border-left: 5px solid #c76c0c;\n",
|
||||
" font-family: 'Open sans',verdana,arial,sans-serif;\n",
|
||||
" width:680px;\n",
|
||||
" padding: 10px 10px 10px 10px;\n",
|
||||
" text-align:justify;\n",
|
||||
" text-justify:inter-word;\n",
|
||||
" }\n",
|
||||
" blockquote p {\n",
|
||||
" margin-bottom: 0;\n",
|
||||
" line-height: 125%;\n",
|
||||
" font-size: 100%;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<script>\n",
|
||||
" MathJax.Hub.Config({\n",
|
||||
" TeX: {\n",
|
||||
" extensions: [\"AMSmath.js\"]\n",
|
||||
" },\n",
|
||||
" tex2jax: {\n",
|
||||
" inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\n",
|
||||
" displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ]\n",
|
||||
" },\n",
|
||||
" displayAlign: 'center', // Change this to 'center' to center equations.\n",
|
||||
" \"HTML-CSS\": {\n",
|
||||
" styles: {'.MathJax_Display': {\"margin\": 4}}\n",
|
||||
" }\n",
|
||||
" });\n",
|
||||
"</script>\n"
|
||||
],
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 2,
|
||||
"output_type": "display_data",
|
||||
"png": "iVBORw0KGgoAAAANSUhEUgAAAq4AAAH8CAYAAAAQUS1nAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XtcVOW+P/DPmuF+FQREUURFBcRLCt4vKCGoqWjmMbva\ntqyTZXVy/9rtOifb7bbdd+19Oq9q77JSs9olpCYoKngPLe+IeEPkfr8NDMPMrN8fHtZxOYCAA2su\nn/frxUvXs9as9Z0Rn/WdZz0XQRRFEUREREREFk6ldABERERERB3BxJWIiIiIrAITVyIiIiKyCkxc\niYiIiMgqKJq4btiwASqVChkZGWY976OPPgqV6s7f2pYtW6BSqaSfQYMGmSE6IiIiIuqKdrO79PR0\nWeJ26485CIIAQRDaPSYpKQnr1q0z6zk7YvLkydi4cSO+/vprhIWFmeWcRERERNQ1QnvTYZWWliIt\nLQ0AsG3bNnz77bf44x//iPDwcADA8uXL7+jiRqMRer0ejo6O7SaFjz76KL766isYjcYOnddgMMBg\nMMDJyemO4rtZTEwM8vLycOXKFbOdk4iIiIg6zqG9nQEBAVJympeXh2+//RZxcXGYPn26WS6uUqk6\nnFx2prVTrVZDrVZ3NSwiIiIiskBmed7f0ld1586dWL16Nfz9/dG7d28sX74ctbW1Jsf7+fnJuhy0\n1sf15m4KX331FURRlL1mxYoVsuPPnj3b4a4MW7Zswfz58xEcHAwXFxcEBgbigQceYGsqERERkQVr\nt8W1s1544QVERETgjTfewC+//IINGzYAADZv3iw77pNPPkFTUxP279+PTz/9tNXW1IiICGzcuFE6\n/sCBA9I2AAwZMkR2fHBwsOz4gwcPthnnRx99BAcHBzz99NPo06cPcnNz8T//8z9IS0tDVlYWevfu\n3aX3T0RERETdx6yJ69ChQ/HDDz8AAFatWoWrV68iKSkJRqNR1gJ67733AgB0Oh0+/fTTVs91czeF\nXbt24cCBA+32qfXy8jI5vi3ff/89goKCZGUxMTGYNWsWvvrqKzz//PMdeLdERERE1JPMOh3WsmXL\nZNtRUVHQarUoLS0152XuWEvSKooiampqUF5ejqFDhwIALl26pGRoRERERNQGsyauffv2lW27u7sD\nuNGyaklOnDiBuXPnwtPTEz4+PggICMCAAQMAAFqtVuHoiIiIiKg1Zu0qYA0j+fPy8jB9+nR4e3vj\nv/7rvxAeHg43Nzfo9XokJCSgndnBiIiIiEhBZk1cu4u5FhQAgK1bt0Kj0eCnn37CzJkzpfLbdRFw\ncnKCXq83SwxERERE1HmKLvnaUZ6enhBFEcXFxR1+TVuJbkur8K2twx988EG75wsODkZxcTFqamo6\nHAMRERERmU+7La6lpaXYtWsXAODkyZMAbozYz8vLAwA8+OCDnb7gkSNHcPnyZenvt55zypQpGDRo\nkOw106ZNw9///nesXLkSjz32GNzc3NC/f39ERkZKxyQlJaG+vh4AcOXKFYiiiE2bNkm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5cuVLaTktLEyMiItq97vTp08Vx48aZ5T0Q\nERGR7RJEsRPrnJLNe+utt/Dmm28iNzcXPj4+nX79f//3f+PEiRNSV4nt27fj7bffbnN1rxLine truncated
|
||||
"text": [
|
||||
"<IPython.core.display.HTML at 0x7e9eeb8>"
|
||||
"<matplotlib.figure.Figure at 0x2778610>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 2
|
||||
"prompt_number": 3
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:b105d6995f19073d8376cf55418d5b1ba33b4d192a9eda1b6733add7091d54b3"
|
||||
"signature": "sha256:410ce21bf24ce671ae0a839a3fed5bea5ddb8cc7d05fb2719f7e8b1d57126411"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
@@ -249,7 +249,8 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"#Introduction\n",
|
||||
"#Discrete Bayes Filter\n",
|
||||
"\n",
|
||||
"The Kalman filter belongs to a family of filters called *bayesian filters*. Without going into"
|
||||
]
|
||||
},
|
||||
@@ -257,7 +258,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Tracking a Dog\n",
|
||||
"### Tracking a Dog\n",
|
||||
"\n",
|
||||
"Let us begin with a simple problem. We have a dog friendly workspace, and so people bring their dogs to work. However, occasionally the dogs wander out of your office and down the halls. We want to be able to track them. So during a hackathon somebody created a little sonar sensor to attach to the dog's collar. It emits a signal, listens for the echo, and based on how quickly an echo comes back we can tell whether the dog is in front of an open doorway or not. It also senses when the dog walks, and reports in which direction the dog has moved. It connects to our network via wifi and sends an update once a second.\n",
|
||||
"\n",
|
||||
+1044
-696
File diff suppressed because it is too large.
Load diff
+118
@@ -0,0 +1,118 @@
|
||||
import numpy as np
|
||||
import pylab as plt
|
||||
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow, FancyArrow
|
||||
|
||||
def create_predict_update_chart(box_bg = '#CCCCCC',
|
||||
arrow1 = '#88CCFF',
|
||||
arrow2 = '#88FF88'):
|
||||
plt.figure(figsize=(6,6), facecolor='w')
|
||||
ax = plt.axes((0, 0, 1, 1),
|
||||
xticks=[], yticks=[], frameon=False)
|
||||
#ax.set_xlim(0, 10)
|
||||
#ax.set_ylim(0, 10)
|
||||
|
||||
|
||||
pc = Circle((4,5), 0.5, fc=box_bg)
|
||||
uc = Circle((6,5), 0.5, fc=box_bg)
|
||||
ax.add_patch (pc)
|
||||
ax.add_patch (uc)
|
||||
|
||||
|
||||
plt.text(4,5, "Predict\nStep",ha='center', va='center', fontsize=14)
|
||||
plt.text(6,5, "Update\nStep",ha='center', va='center', fontsize=14)
|
||||
|
||||
#btm
|
||||
ax.annotate('',
|
||||
xy=(4.1, 4.5), xycoords='data',
|
||||
xytext=(6, 4.5), textcoords='data',
|
||||
size=20,
|
||||
arrowprops=dict(arrowstyle="simple",
|
||||
fc="0.6", ec="none",
|
||||
patchB=pc,
|
||||
patchA=uc,
|
||||
connectionstyle="arc3,rad=-0.5"))
|
||||
#top
|
||||
ax.annotate('',
|
||||
xy=(6, 5.5), xycoords='data',
|
||||
xytext=(4.1, 5.5), textcoords='data',
|
||||
size=20,
|
||||
arrowprops=dict(arrowstyle="simple",
|
||||
fc="0.6", ec="none",
|
||||
patchB=uc,
|
||||
patchA=pc,
|
||||
connectionstyle="arc3,rad=-0.5"))
|
||||
|
||||
|
||||
ax.annotate('Measurement ($\mathbf{z_k}$)',
|
||||
xy=(6.3, 5.4), xycoords='data',
|
||||
xytext=(6,6), textcoords='data',
|
||||
size=18,
|
||||
arrowprops=dict(arrowstyle="simple",
|
||||
fc="0.6", ec="none"))
|
||||
|
||||
ax.annotate('',
|
||||
xy=(4.0, 3.5), xycoords='data',
|
||||
xytext=(4.0,4.5), textcoords='data',
|
||||
size=18,
|
||||
arrowprops=dict(arrowstyle="simple",
|
||||
fc="0.6", ec="none"))
|
||||
|
||||
ax.annotate('Initial\nConditions ($\mathbf{x_0}$)',
|
||||
xy=(4.0, 5.5), xycoords='data',
|
||||
xytext=(2.5,6.5), textcoords='data',
|
||||
size=18,
|
||||
arrowprops=dict(arrowstyle="simple",
|
||||
fc="0.6", ec="none"))
|
||||
|
||||
plt.text (4,3.4,'State Estimate ($\mathbf{\hat{x}_k}$)',
|
||||
ha='center', va='center', fontsize=18)
|
||||
plt.axis('equal')
|
||||
#plt.axis([0,8,0,8])
|
||||
plt.show()
|
||||
|
||||
|
||||
def plot_estimate_chart_1():
|
||||
ax = plt.axes()
|
||||
ax.annotate('', xy=[1,159], xytext=[0,158],
|
||||
arrowprops=dict(arrowstyle='->', ec='r',shrinkA=6, lw=3,shrinkB=5))
|
||||
plt.scatter ([0], [158], c='b')
|
||||
plt.scatter ([1], [159], c='r')
|
||||
plt.show()
|
||||
|
||||
|
||||
def plot_estimate_chart_2():
|
||||
ax = plt.axes()
|
||||
ax.annotate('', xy=[1,159], xytext=[0,158],
|
||||
arrowprops=dict(arrowstyle='->',
|
||||
ec='r', lw=3, shrinkA=6, shrinkB=5))
|
||||
plt.scatter ([0], [158.0], c='k',s=128)
|
||||
plt.scatter ([1], [164.2], c='b',s=128)
|
||||
plt.scatter ([1], [159], c='r', s=128)
|
||||
plt.text (1.0, 158.8, "prediction ($\hat{x}_{t})$", ha='center',va='top',fontsize=18,color='red')
|
||||
plt.text (1.0, 164.4, "measurement ($z$)",ha='center',va='bottom',fontsize=18,color='blue')
|
||||
plt.text (0, 157.8, "estimate ($\hat{x}_{t-1}$)", ha='center', va='top',fontsize=18)
|
||||
plt.show()
|
||||
|
||||
def plot_estimate_chart_3():
|
||||
ax = plt.axes()
|
||||
ax.annotate('', xy=[1,159], xytext=[0,158],
|
||||
arrowprops=dict(arrowstyle='->',
|
||||
ec='r', lw=3, shrinkA=6, shrinkB=5))
|
||||
|
||||
ax.annotate('', xy=[1,159], xytext=[1,164.2],
|
||||
arrowprops=dict(arrowstyle='-',
|
||||
ec='k', lw=1, shrinkA=8, shrinkB=8))
|
||||
|
||||
est_y = ((164.2-158)*.8 + 158)
|
||||
plt.scatter ([0,1], [158.0,est_y], c='k',s=128)
|
||||
plt.scatter ([1], [164.2], c='b',s=128)
|
||||
plt.scatter ([1], [159], c='r', s=128)
|
||||
plt.text (1.0, 158.8, "prediction ($\hat{x}_{t})$", ha='center',va='top',fontsize=18,color='red')
|
||||
plt.text (1.0, 164.4, "measurement ($z$)",ha='center',va='bottom',fontsize=18,color='blue')
|
||||
plt.text (0, 157.8, "estimate ($\hat{x}_{t-1}$)", ha='center', va='top',fontsize=18)
|
||||
plt.text (0.95, est_y, "new estimate ($\hat{x}_{t}$)", ha='right', va='center',fontsize=18)
|
||||
plt.show()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
create_predict_update_chart()
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:62a110cf58205ec15bdd741effe2f73f0740853316b38e5a0a3edbc2d1cd7157"
|
||||
"signature": "sha256:e5b629cac25efb2c3f414af72bb7b250b7a1a8bb7c1497c44a76c76ad4206ff6"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
@@ -21,12 +21,18 @@
|
||||
"\n",
|
||||
"Motivation for the book. Where to download, how to use.\n",
|
||||
"\n",
|
||||
"** add something about teaching methodology. exploration vs regurgitation.\n",
|
||||
"\n",
|
||||
"[**Introduction**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/Introduction.ipynb)\n",
|
||||
" \n",
|
||||
"Introduction to the Kalman filter. Explanation of the idea behind this book.\n",
|
||||
"Yes, it is more or less the preface restated. will edit and delete one or the other.\n",
|
||||
"\n",
|
||||
"[**Chapter 0: Signals and Noise**](Nada)\n",
|
||||
"\n",
|
||||
"A brief introduction to signals and noise. Nomenclature and sample code.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"[**Chapter 1: The g-h Filter**](http://nbviewer.ipython.org/urls/raw.github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/g-h_filter.ipynb)\n",
|
||||
"\n",
|
||||
|
||||
Reference in new issue
Block a user