In [1]:
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='..')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-088e253ce17b> in <module>
      7 # consistant with that look and feel.
      8 import book_format
----> 9 book_format.load_style(directory='..')

AttributeError: module 'book_format' has no attribute 'load_style'
In [2]:
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))
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-5ca8afccfac5> in <module>
      1 import numpy as np
      2 import matplotlib.pyplot as plt
----> 3 from gif_animate import animate
      4 from stats import gaussian
      5 import matplotlib.pylab as pylab

ModuleNotFoundError: No module named 'gif_animate'
In [2]: