Created
January 1, 2016 15:45
-
-
Save iconjack/3112305682674977a9b2 to your computer and use it in GitHub Desktop.
shows what happens when you mix large and small sample sizes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from pylab import savefig | |
import numpy as np | |
from numpy.random import rand, randint | |
def flipsome(n): | |
flip = lambda: randint(0,2) | |
return sum(flip() for _ in range(n)) / float(n) | |
interval = 1000 | |
begin, end = -450000, 0 | |
length = end-begin | |
intervals = length/interval | |
a = np.linspace(begin,end,intervals+1) | |
for i in range(1,21): | |
b = [flipsome(interval) for _ in range(intervals)] | |
b.append(flipsome(65)) # final data point | |
fig, ax = plt.subplots() | |
fig.patch.set_visible(False) | |
ax.axis('off') | |
plt.plot(a,b) | |
savefig('figure %s.png' % i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment