.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_data_analysis/sample_analysis/plot_visualize_empirical_cdf.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_auto_data_analysis_sample_analysis_plot_visualize_empirical_cdf.py: Draw the empirical CDF ====================== .. GENERATED FROM PYTHON SOURCE LINES 7-8 In this example we are going to draw the empirical CDF of an unidimensional sample. .. GENERATED FROM PYTHON SOURCE LINES 10-15 .. code-block:: Python import openturns as ot import openturns.viewer as viewer from matplotlib import pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 16-17 Then create a sample from a Gaussian distribution. .. GENERATED FROM PYTHON SOURCE LINES 19-23 .. code-block:: Python size = 100 normal = ot.Normal(1) sample = normal.getSample(size) .. GENERATED FROM PYTHON SOURCE LINES 24-26 We draw the empirical CDF based on the :class:`~openturns.UserDefined` distribution. By default, the `drawCDF` method requires no input argument. .. GENERATED FROM PYTHON SOURCE LINES 28-32 .. code-block:: Python distribution = ot.UserDefined(sample) graph = distribution.drawCDF() view = viewer.View(graph) .. image-sg:: /auto_data_analysis/sample_analysis/images/sphx_glr_plot_visualize_empirical_cdf_001.svg :alt: X0 CDF :srcset: /auto_data_analysis/sample_analysis/images/sphx_glr_plot_visualize_empirical_cdf_001.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 33-35 If required, we can specify the interval that we want to draw. In the following example, these bounds are computed from the minimum and the maximum of the sample. .. GENERATED FROM PYTHON SOURCE LINES 37-42 .. code-block:: Python xmin = sample.getMin()[0] - 2.0 xmax = sample.getMax()[0] + 2.0 graph = ot.UserDefined(sample).drawCDF(xmin, xmax) view = viewer.View(graph) plt.show() .. image-sg:: /auto_data_analysis/sample_analysis/images/sphx_glr_plot_visualize_empirical_cdf_002.svg :alt: X0 CDF :srcset: /auto_data_analysis/sample_analysis/images/sphx_glr_plot_visualize_empirical_cdf_002.svg :class: sphx-glr-single-img .. _sphx_glr_download_auto_data_analysis_sample_analysis_plot_visualize_empirical_cdf.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_visualize_empirical_cdf.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_visualize_empirical_cdf.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_visualize_empirical_cdf.zip `