.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "intro/scipy/auto_examples/plot_t_test.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` 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 ========================================== .. GENERATED FROM PYTHON SOURCE LINES 7-25 .. image-sg:: /intro/scipy/auto_examples/images/sphx_glr_plot_t_test_001.png :alt: plot t test :srcset: /intro/scipy/auto_examples/images/sphx_glr_plot_t_test_001.png :class: sphx-glr-single-img .. code-block:: default import numpy as np import matplotlib.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() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.090 seconds) .. _sphx_glr_download_intro_scipy_auto_examples_plot_t_test.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_t_test.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_t_test.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_