Last active
February 19, 2020 20:21
-
-
Save NataliiaRastoropova/86fc19c8bc85602c64865930a6925ca2 to your computer and use it in GitHub Desktop.
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
array1 = [] | |
array2 = [] | |
array3 = [] | |
array4 = [] | |
n = 300 | |
for i in range(1,n): | |
array1.append(df['CoffeeCupsPerDay'].sample(n=10, replace= True).mean()) | |
array2.append(df['CoffeeCupsPerDay'].sample(n=40, replace=True).mean()) | |
array4.append(df['CoffeeCupsPerDay'].sample(n=60, replace=True).mean()) | |
array3.append(df['CoffeeCupsPerDay'].sample(n=80, replace=True).mean()) | |
fig, ax = plot.subplots() | |
fig = sns.distplot(array1, hist=True, kde=True, | |
bins=8, color = 'y', | |
hist_kws={'edgecolor':'black'}, | |
kde_kws={'linewidth': 4}) | |
ax.set_xlabel('CoffeeCupsPerDay') | |
ax.set_ylabel('Frequency') | |
ax.set_title('Sample size = 10') | |
plot.axvline(np.mean(array1), color='k', linestyle='dashed', linewidth=1) | |
min_ylim, max_ylim = plot.ylim() | |
plot.text(np.mean(array1)*1.1, max_ylim*0.9, 'Mean: {:.2f}'.format(np.mean(array1))) | |
plot.show() | |
fig, ax = plot.subplots() | |
fig = sns.distplot(array2, hist=True, kde=True, | |
bins=8, color = 'm', | |
hist_kws={'edgecolor':'black'}, | |
kde_kws={'linewidth': 4}) | |
ax.set_xlabel('CoffeeCupsPerDay') | |
ax.set_ylabel('Frequency') | |
ax.set_title('Sample size = 40') | |
plot.axvline(np.mean(array2), color='k', linestyle='dashed', linewidth=1) | |
min_ylim, max_ylim = plot.ylim() | |
plot.text(np.mean(array2)*1.1, max_ylim*0.9, 'Mean: {:.2f}'.format(np.mean(array2))) | |
plot.show() | |
fig, ax = plot.subplots() | |
fig = sns.distplot(array3, hist=True, kde=True, | |
bins=8, color = 'g', | |
hist_kws={'edgecolor':'black'}, | |
kde_kws={'linewidth': 4}) | |
ax.set_xlabel('CoffeeCupsPerDay') | |
ax.set_ylabel('Frequency') | |
ax.set_title('Sample size = 60') | |
plot.axvline(np.mean(array3), color='k', linestyle='dashed', linewidth=1) | |
min_ylim, max_ylim = plot.ylim() | |
plot.text(np.mean(array3)*1.1, max_ylim*0.9, 'Mean: {:.2f}'.format(np.mean(array3))) | |
plot.show() | |
fig, ax = plot.subplots() | |
fig = sns.distplot(array4, hist=True, kde=True, | |
bins=8, color = 'b', | |
hist_kws={'edgecolor':'black'}, | |
kde_kws={'linewidth': 4}) | |
ax.set_xlabel('CoffeeCupsPerDay') | |
ax.set_ylabel('Frequency') | |
ax.set_title('Sample size = 80') | |
plot.axvline(np.mean(array4), color='k', linestyle='dashed', linewidth=1) | |
min_ylim, max_ylim = plot.ylim() | |
plot.text(np.mean(array4)*1.1, max_ylim*0.9, 'Mean: {:.2f}'.format(np.mean(array4))) | |
plot.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment