Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rlabbe
GitHub Repository: rlabbe/Kalman-and-Bayesian-Filters-in-Python
Path: blob/master/animations/Gaussians_Animations.ipynb
687 views
Kernel: Python 3
%matplotlib inline import sys sys.path.insert(0,'..') # allow us to format the book # use same formatting as rest of book so that the plots are # consistant with that look and feel. import book_format book_format.set_style()
import numpy as np import matplotlib.pyplot as plt from kf_book.gif_animate import animate from stats import gaussian import matplotlib.pylab as pylab from matplotlib import animation import matplotlib def plt_g (mu, variance): xs = np.arange(2,8,0.05) ys = [gaussian (x, mu, variance) for x in xs] plt.plot (xs, ys) plt.ylim((0,1)) mu = 2 sigma = 0.6 def ganimate(frame): global mu, sigma if frame < 25: mu += .2 elif frame == 25: mu = 5 elif frame < 37: sigma -= 0.05 else: sigma += 0.05 plt.cla() plt_g(mu,sigma) animate('04_gaussian_animate.gif', ganimate, frames=80, interval=50, figsize=(6,4))
Image in a Jupyter notebook