CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download
Project: test
Views: 91872
Kernel: Python 3
from __future__ import division, print_function %matplotlib inline import sys sys.path.insert(0,'..') # allow us to format the book sys.path.insert(0,'../code') # use same formatting as rest of book so that the plots are # consistant with that look and feel. import book_format book_format.load_style(directory='..')
import numpy as np import matplotlib.pyplot as plt from 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