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:
parent
64f61bbc31
commit
82c5cbe71c
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
Chapter02_Discrete_Bayes/no_info.gif
Normal file
BIN
Chapter02_Discrete_Bayes/no_info.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 288 KiB |
BIN
Chapter02_Discrete_Bayes/simulate.gif
Normal file
BIN
Chapter02_Discrete_Bayes/simulate.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 203 KiB |
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user