Edit to fit on 6x9 book.

Somewhat arbitrary, but I want the code to be readable on
narrow paper than 8.5x11.
This commit is contained in:
Roger Labbe
2015-07-25 23:46:59 -07:00
parent 82f4e1569b
commit 925498a19e
21 changed files with 1445 additions and 1533 deletions

34
code/kf_internal.py Normal file
View File

@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 25 17:13:23 2015
@author: rlabbe
"""
import book_plots as bp
import matplotlib.pyplot as plt
def plot_dog_track(xs, measurement_var, process_var):
N = len(xs)
bp.plot_track([0, N-1], [1, N])
bp.plot_measurements(xs, label='Sensor')
bp.set_labels('variance = {}, process variance = {}'.format(
measurement_var, process_var), 'time', 'pos')
plt.ylim([0, N])
bp.show_legend()
plt.show()
def print_gh(predict, update, z):
predict_template = 'PREDICT: {: 6.2f} {: 6.2f}'
update_template = 'UPDATE: {: 6.2f} {: 6.2f}\tZ: {:.2f}'
print(predict_template.format(predict[0], predict[1]),end='\t')
print(update_template.format(update[0], update[1], z))
def print_variance(positions):
print('Variance:')
for i in range(0, len(positions), 5):
print('\t{:.4f} {:.4f} {:.4f} {:.4f} {:.4f}'.format(
*[v[1] for v in positions[i:i+5]]))