Added license text and import from future.

This code did not work for Python 2.x becaus I was not
importing from future. While I was altering all the files
I updated the header to include license information.
This commit is contained in:
Roger Labbe 2015-08-01 08:46:14 -07:00
parent df2b92db79
commit 6bf7552212
18 changed files with 288 additions and 83 deletions

View File

@ -1,14 +1,24 @@
# -*- coding: utf-8 -*-
"""
Created on Sun May 11 13:21:39 2014
@author: rlabbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import print_function, division
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from numpy.random import randn
import math
from numpy.random import randn
class DogSimulation(object):

View File

@ -1,12 +1,23 @@
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 27 19:45:45 2015
@author: Roger
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import numpy as np
import numpy.random
from numpy.random import randn, random, uniform
import scipy.stats

View File

@ -1,12 +1,23 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 30 19:48:21 2015
@author: rlabbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
import matplotlib.pyplot as plt
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import book_plots as bp
import matplotlib.pyplot as plt
def plot_track_and_residuals(t, xs, z_xs, res):
@ -26,6 +37,3 @@ def plot_track_and_residuals(t, xs, z_xs, res):
plt.ylabel('residual')
plt.title('residuals')
plt.show()

View File

@ -1,5 +1,20 @@
# -*- coding: utf-8 -*-
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from contextlib import contextmanager
from IPython.core.display import HTML

View File

@ -1,9 +1,22 @@
# -*- coding: utf-8 -*-
"""
Created on Fri May 2 12:21:40 2014
@author: rlabbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import matplotlib.pyplot as plt
import numpy as np
@ -133,7 +146,7 @@ def plot_track(xs, ys=None, label='Track', c='k', lw=2, **kwargs):
plt.plot(xs, color=c, lw=lw, ls=':', label=label, **kwargs)
def plot_filter(xs, ys=None, c='#013afe', label='Filter', vars=None, **kwargs):
def plot_filter(xs, ys=None, c='#013afe', label='Filter', var=None, **kwargs):
#def plot_filter(xs, ys=None, c='#6d904f', label='Filter', vars=None, **kwargs):
@ -143,12 +156,12 @@ def plot_filter(xs, ys=None, c='#013afe', label='Filter', vars=None, **kwargs):
plt.plot(xs, ys, color=c, label=label, **kwargs)
if vars is None:
if var is None:
return
print('here')
vars = np.asarray(vars)
std = np.sqrt(vars)
var = np.asarray(var)
std = np.sqrt(var)
std_top = ys+std
std_btm = ys-std

View File

@ -1,16 +1,27 @@
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 18 23:23:08 2014
@author: rlabbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import book_plots as bp
from math import radians, sin, cos, sqrt, exp
import numpy.random as random
import matplotlib.pyplot as plt
import filterpy.kalman as kf
from math import radians, sin, cos, sqrt, exp
import matplotlib.pyplot as plt
import numpy as np
import numpy.random as random
def ball_kf(x, y, omega, v0, dt, r=0.5, q=0.02):

View File

@ -1,15 +1,25 @@
# -*- coding: utf-8 -*-
"""
Created on Thu May 8 23:16:31 2014
@author: rlabbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import filterpy.stats as stats
import math
import matplotlib.pylab as pylab
import matplotlib.pyplot as plt
import numpy as np
import filterpy.stats as stats
def plot_height_std(x, lw=10):
m = np.mean(x)

View File

@ -1,8 +1,26 @@
import numpy as np
import pylab as plt
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow, FancyArrow
import book_plots
# -*- coding: utf-8 -*-
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import book_format
import book_plots
import numpy as np
from matplotlib.patches import Circle, Rectangle, Polygon, Arrow, FancyArrow
import pylab as plt
def plot_errorbar1():
with book_format.figsize(y=1.5):

View File

@ -1,10 +1,21 @@
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 14 12:41:24 2014
@author: rlabbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from matplotlib import animation
import matplotlib.pyplot as plt

View File

@ -1,10 +1,21 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 13 13:20:27 2015
@author: Roger
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from filterpy.kalman import UnscentedKalmanFilter as UKF
from filterpy.kalman import JulierSigmaPoints
from math import atan2

View File

@ -1,10 +1,21 @@
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 25 17:13:23 2015
@author: rlabbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import book_plots as bp
import matplotlib.pyplot as plt
@ -20,8 +31,8 @@ def plot_dog_track(xs, measurement_var, process_var):
def print_gh(predict, update, z):
predict_template = 'PREDICT: {: 6.2f} {: 6.2f}'
update_template = 'UPDATE: {: 6.2f} {: 6.2f}\tZ: {:.2f}'
predict_template = ' {: 7.3f} {: 8.3f}'
update_template = '{: 7.3f} {: 7.3f}\t {:.3f}'
print(predict_template.format(predict[0], predict[1]),end='\t')
print(update_template.format(update[0], update[1], z))

View File

@ -1,16 +1,28 @@
# -*- coding: utf-8 -*-
"""
Created on Thu May 1 16:56:49 2014
@author: rlabbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import filterpy.stats as stats
from filterpy.stats import plot_covariance_ellipse
import numpy as np
from matplotlib.patches import Ellipse
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from numpy.random import multivariate_normal

View File

@ -1,13 +1,23 @@
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 9 13:02:32 2015
@author: Roger Labbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import filterpy.stats as stats
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
import numpy as np

View File

@ -1,11 +1,20 @@
# -*- coding: utf-8 -*-
"""
Created on Sun May 18 11:09:23 2014
@author: rlabbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import division
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from filterpy.stats import multivariate_gaussian
from matplotlib import cm

View File

@ -1,29 +1,32 @@
# -*- coding: utf-8 -*-
"""
Created on Sat May 2 09:46:06 2015
@author: Roger
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import math
import matplotlib.pyplot as plt
import numpy as np
from numpy.random import uniform
from numpy.random import randn
import scipy.stats
import matplotlib.pyplot as plt
import random
if __name__ == '__main__':
N = 2000
pf = ParticleFilter(N, 100, 100)
@ -33,7 +36,7 @@ if __name__ == '__main__':
#pf.create_particles(mean=z, variance=40)
mu0 = np.array([0., 0.])
plot(pf, weights=False)
plt.plot(pf, weights=False)
fig = plt.gcf()

View File

@ -1,3 +1,22 @@
# -*- coding: utf-8 -*-
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from filterpy.monte_carlo import stratified_resample
import matplotlib as mpl
import matplotlib.pyplot as plt
@ -5,7 +24,6 @@ import matplotlib.pyplot as plt
import numpy as np
from numpy.random import randn, random, uniform, multivariate_normal, seed
#from nonlinear_plots import plot_monte_carlo_mean
import pylab as plt
import scipy.stats
from RobotLocalizationParticleFilter import *

View File

@ -1,9 +1,21 @@
# -*- coding: utf-8 -*-
"""
Created on Tue May 27 21:21:19 2014
@author: rlabbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import matplotlib.pyplot as plt

View File

@ -1,9 +1,21 @@
# -*- coding: utf-8 -*-
"""
Created on Tue May 27 21:21:19 2014
@author: rlabbe
"""Copyright 2015 Roger R Labbe Jr.
Code supporting the book
Kalman and Bayesian Filters in Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from filterpy.kalman import UnscentedKalmanFilter as UKF
from filterpy.kalman import MerweScaledSigmaPoints
import filterpy.stats as stats