In [1]:
import time
print('Last updated:', time.strftime('%m/%d/%Y'))
In [2]:
%matplotlib inline
In [3]:
import numpy as np
import random
from matplotlib import pyplot as plt
data = [random.gauss(10,10) for i in range(1000)]
bins = np.arange(-60, 60, 5)
plt.xlim([min(data)-5, max(data)+5])
plt.hist(data, bins=bins, alpha=0.5)
plt.title('Random Gaussian data')
plt.xlabel('variable X')
plt.ylabel('count')
plt.show()
In [4]:
import numpy as np
import random
from matplotlib import pyplot as plt
data1 = [random.gauss(15,10) for i in range(500)]
data2 = [random.gauss(5,5) for i in range(500)]
bins = np.arange(-60, 60, 2.5)
plt.xlim([min(data1+data2)-5, max(data1+data2)+5])
plt.hist(data1, bins=bins, alpha=0.3, label='class 1')
plt.hist(data2, bins=bins, alpha=0.3, label='class 2')
plt.title('Random Gaussian data')
plt.xlabel('variable X')
plt.ylabel('count')
plt.legend(loc='upper right')
plt.show()