Skip to content

Instantly share code, notes, and snippets.

@rohanjoseph93
Created September 4, 2018 01:04
Show Gist options
  • Save rohanjoseph93/3ce8a91967fa27fbdb64ecb1d6332e8b to your computer and use it in GitHub Desktop.
Save rohanjoseph93/3ce8a91967fa27fbdb64ecb1d6332e8b to your computer and use it in GitHub Desktop.
# Function that will plot the histogram, where current is the latest figure
def clt(current):
# if animation is at the last frame, stop it
plt.cla()
if current == 1000:
a.event_source.stop()
plt.hist(avg[0:current])
plt.gca().set_title('Expected value of die rolls')
plt.gca().set_xlabel('Average from die roll')
plt.gca().set_ylabel('Frequency')
plt.annotate('Die roll = {}'.format(current), [3,27])
fig = plt.figure()
a = animation.FuncAnimation(fig, clt, interval=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment