.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_intro_scipy_auto_examples_plot_t_test.py: ========================================== Comparing 2 sets of samples from Gaussians ========================================== .. image:: /intro/scipy/auto_examples/images/sphx_glr_plot_t_test_001.png :class: sphx-glr-single-img .. code-block:: python 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) .. _sphx_glr_download_intro_scipy_auto_examples_plot_t_test.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_t_test.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_t_test.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_