Skip to content

Instantly share code, notes, and snippets.

@acharles7
Created March 11, 2020 01:11
Show Gist options
  • Save acharles7/0e403a17e541d28d38cdb82cb42b7542 to your computer and use it in GitHub Desktop.
Save acharles7/0e403a17e541d28d38cdb82cb42b7542 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
# generate random data and plot them
data = np.random.random_integers(10, 20, 100)
num, count = np.unique(data, return_counts=True)
plt.plot(num, count)
each_sample_size = 10
sample_size = 500
sample_average = []
for i in range(sample_size):
sample_average.append(np.random.choice(data, each_sample_size).mean())
# generate normal distributed plot
mean, mean_count = np.unique(sample_average, return_counts=True)
plt.plot(mean, mean_count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment