.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/statistics/descriptive/plot_01_five_number_summary.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_api_gallery_statistics_descriptive_plot_01_five_number_summary.py: Descriptive statistics and the five-number summary ========================================================= Summarizes a skewed dataset (exponential-ish waiting times) and visualizes its five-number summary as a boxplot. .. GENERATED FROM PYTHON SOURCE LINES 10-15 .. code-block:: Python import numpy as np from mathematicskit.statistics import descriptive_stats from mathematicskit.statistics.visualizers.plots import plot_boxplot .. GENERATED FROM PYTHON SOURCE LINES 16-18 Generate a right-skewed dataset and summarize it ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 18-27 .. code-block:: Python rng = np.random.default_rng(0) data = rng.exponential(scale=3.0, size=500) result = descriptive_stats(data) print(f"n={result.n}, mean={result.mean:.3f}, std={result.std:.3f}") print(f"skewness={result.skewness:.3f} (positive: right-skewed, as expected for an exponential)") print(f"five-number summary: [{result.minimum:.2f}, {result.q1:.2f}, {result.median:.2f}, {result.q3:.2f}, {result.maximum:.2f}]") .. rst-class:: sphx-glr-script-out .. code-block:: none n=500, mean=3.289, std=3.152 skewness=2.087 (positive: right-skewed, as expected for an exponential) five-number summary: [0.00, 1.00, 2.39, 4.54, 24.39] .. GENERATED FROM PYTHON SOURCE LINES 28-30 Visualize the five-number summary ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 30-32 .. code-block:: Python plot_boxplot(data, label="waiting times") .. image-sg:: /api/gallery/statistics/descriptive/images/sphx_glr_plot_01_five_number_summary_001.png :alt: Boxplot :srcset: /api/gallery/statistics/descriptive/images/sphx_glr_plot_01_five_number_summary_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.016 seconds) .. _sphx_glr_download_api_gallery_statistics_descriptive_plot_01_five_number_summary.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_five_number_summary.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_five_number_summary.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_five_number_summary.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_