Changes to condense material.

Lots of small changes to try to get page count down. I'm not liking
this.
This commit is contained in:
Roger Labbe 2015-04-20 17:14:51 -07:00
parent dda63fb329
commit 8bae16b811
10 changed files with 963 additions and 931 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Installation, Python, Numpy, and filterpy"
"# Installation, Python, NumPy, and FilterPy"
]
},
{
@ -271,7 +271,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This book is written in IPython Notebook, a browser based interactive Python environment that mixes Python, text, and math. I choose it because of the interactive features - I found Kalman filtering nearly impossible to learn until I started working in an interactive environment. It is difficult to form an intuition of the effect of many of the parameters that you can tune until you can change them rapidly and immediately see the output. An interactive environment also allows you to play 'what if' scenarios out. \"What if I set $\\mathbf{Q}$ to zero?\" It is trivial to find out with Ipython Notebook.\n",
"This book is written in IPython Notebook, a browser based interactive Python environment that mixes Python, text, and math. I choose it because of the interactive features - I found Kalman filtering nearly impossible to learn until I started working in an interactive environment. It is difficult to form an intuition of the effect of many of the parameters that you can tune until you can change them rapidly and immediately see the output. An interactive environment also allows you to play 'what if' scenarios out. \"What if I set $\\mathbf{Q}$ to zero?\" It is trivial to find out with IPython Notebook.\n",
"\n",
"Another reason I choose it is because I find that a typical textbook leaves many things opaque. For example, there might be a beautiful plot next to some pseudocode. That plot was produced by software, but software that is not available to me as a reader. I want everything that went into producing this book to be available to the reader. How do you plot a covariance ellipse? You won't know if you read most books. With IPython Notebook all you have to do is look at the source code.\n",
"\n",
@ -300,6 +300,22 @@
"There are other choices for installing the SciPy stack. The SciPy stack provides instructions here: http://scipy.org/install.html"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Installing FilterPy\n",
"\n",
"FilterPy is a Python library that implements all of the filters used in this book, and quite a few not used by this book. Installation is easy using Pip. Issue the following command from the command prompt.\n",
"\n",
" pip install filterpy\n",
" \n",
" \n",
"FilterPy is written by me, and the latest development version is always available at github.com/rlabbe/filterpy.\n",
" \n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
@ -775,7 +791,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.2"
"version": "3.4.3"
}
},
"nbformat": 4,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 690 KiB

After

Width:  |  Height:  |  Size: 501 KiB

File diff suppressed because one or more lines are too long

View File

@ -72,19 +72,34 @@ def plot_residual_limits(Ps):
facecolor='#ffff00', alpha=0.3)
def plot_track(xs, ys=None, label='Track', c='k', lw=2):
def plot_track(xs, ys=None, label='Track', c='k', lw=2, **kwargs):
if ys is not None:
plt.plot(xs, ys, c=c, lw=lw, label=label)
plt.plot(xs, ys, c=c, lw=lw, label=label, **kwargs)
else:
plt.plot(xs, c=c, lw=lw, label=label)
plt.plot(xs, c=c, lw=lw, label=label, **kwargs)
#c='#013afe'
def plot_filter(xs, ys=None, c='#6d904f', label='Filter', **kwargs):
if ys is not None:
plt.plot(xs, ys, c=c, label=label, **kwargs)
else:
plt.plot(xs, c=c, label=label, **kwargs)
def plot_filter(xs, ys=None, c='#6d904f', label='Filter', vars=None, **kwargs):
if ys is None:
ys = xs
xs = range(len(ys))
plt.plot(xs, ys, c=c, label=label, **kwargs)
if vars is None:
return
vars = np.asarray(vars)
std = np.sqrt(vars)
std_top = ys+std
std_btm = ys-std
plt.plot(xs, ys+std, linestyle=':', c='k', lw=2)
plt.plot(xs, ys-std, linestyle=':', c='k', lw=2)
plt.fill_between(xs, std_btm, std_top,
facecolor='yellow', alpha=0.2)
if __name__ == "__main__":

View File

@ -11,6 +11,22 @@ import matplotlib.pyplot as plt
import numpy as np
import stats
def plot_height_std(x, lw=10):
m = np.mean(x)
s = np.std(x)
for i, height in enumerate(x):
plt.plot([i+1, i+1], [0, height], color='k', lw=lw)
plt.xlim(0,len(x)+1)
plt.axhline(m-s, ls='--')
plt.axhline(m+s, ls='--')
plt.fill_between((0, len(x)+1), m-s, m+s,
facecolor='yellow', alpha=0.4)
plt.xlabel('student')
plt.ylabel('height (m)')
plt.show()
def plot_gaussian (mu, variance,
mu_line=False,
xlim=None,
@ -31,8 +47,6 @@ def plot_gaussian (mu, variance,
plt.show()
def display_stddev_plot():
figsize = pylab.rcParams['figure.figsize']
pylab.rcParams['figure.figsize'] = 12,6
xs = np.arange(10,30,0.1)
var = 8; stddev = math.sqrt(var)
p2, = plt.plot (xs,[stats.gaussian(x, 20, var) for x in xs])

View File

@ -6,7 +6,7 @@ import book_plots
def create_predict_update_chart(box_bg = '#CCCCCC',
arrow1 = '#88CCFF',
arrow2 = '#88FF88'):
plt.figure(figsize=(6,6), facecolor='w')
plt.figure(figsize=(4,4), facecolor='w')
ax = plt.axes((0, 0, 1, 1),
xticks=[], yticks=[], frameon=False)
#ax.set_xlim(0, 10)
@ -187,13 +187,12 @@ def plot_hypothesis5():
plt.show()
def plot_g_h_results(measurements, filtered_data,
title='', z_label='Scale', ):
title='', z_label='Measurements', **kwargs):
book_plots.plot_filter(filtered_data, **kwargs)
book_plots.plot_measurements(measurements, label=z_label)
book_plots.plot_filter(filtered_data)
book_plots.show_legend()
plt.title(title)
plt.gca().set_xlim(left=0,right=len(measurements))
plt.show()
if __name__ == '__main__':
create_predict_update_chart()

View File

@ -157,6 +157,7 @@ def multivariate_gaussian(x, mu, cov):
def plot_gaussian(mean, variance,
mean_line=False,
xlim=None,
ylim=None,
xlabel=None,
ylabel=None):
""" plots the normal distribution with the given mean and variance. x-axis
@ -182,6 +183,9 @@ def plot_gaussian(mean, variance,
plt.plot(xs,n.pdf(xs))
plt.xlim((min_x, max_x))
if ylim is not None:
plt.ylim(ylim)
if mean_line:
plt.axvline(mean)
if xlabel: