Added animations to Discrete Bayes

Beginning of adding animations to the chapters. I wrote the
existing material not assuming animations, so it is quite
possible that I will want to revise the chapter to better
make use of this ability. For now I just animated two different
update/predict cycles.
This commit is contained in:
Roger Labbe
2014-09-13 11:15:40 -07:00
parent 64f61bbc31
commit 82c5cbe71c
5 changed files with 488 additions and 63 deletions

View File

@@ -7,16 +7,18 @@ Created on Fri May 2 12:21:40 2014
import matplotlib.pyplot as plt
import numpy as np
def plot(pos, ylim=(0,1)):
def plot(pos, ylim=(0,1), title=None):
plt.cla()
ax = plt.gca()
x = np.arange(len(pos))
ax.bar(x, pos)
if ylim:
plt.ylim([0,1])
plt.ylim(ylim)
plt.xticks(x+0.4, x)
plt.grid()
plt.show()
if title is not None:
plt.title(title)
if __name__ == "__main__":
p = [0.2245871, 0.06288015, 0.06109133, 0.0581008, 0.09334062, 0.2245871,