1.6.12.5. Comparing 2 sets of samples from GaussiansΒΆ

../../../_images/sphx_glr_plot_t_test_001.png
import numpy as np
from matplotlib import pyplot as plt
# Generates 2 sets of observations
samples1 = np.random.normal(0, size=1000)
samples2 = np.random.normal(1, size=1000)
# Compute a histogram of the sample
bins = np.linspace(-4, 4, 30)
histogram1, bins = np.histogram(samples1, bins=bins, density=True)
histogram2, bins = np.histogram(samples2, bins=bins, density=True)
plt.figure(figsize=(6, 4))
plt.hist(samples1, bins=bins, density=True, label="Samples 1")
plt.hist(samples2, bins=bins, density=True, label="Samples 2")
plt.legend(loc='best')
plt.show()

Total running time of the script: ( 0 minutes 0.042 seconds)

Gallery generated by Sphinx-Gallery