.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` 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
======================
In this example we are going to draw the empirical CDF of an unidimensional sample.
.. code-block:: default
from __future__ import print_function
import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt
ot.Log.Show(ot.Log.NONE)
Then create a sample from a gaussian distribution.
.. code-block:: default
size = 100
normal = ot.Normal(1)
sample = normal.getSample(size)
We draw the empirical CDF based on the `UserDefined` distribution. By default, the `drawCDF` method requires no input argument.
.. code-block:: default
distribution = ot.UserDefined(sample)
graph = distribution.drawCDF()
view = viewer.View(graph)
.. image:: /auto_data_analysis/sample_analysis/images/sphx_glr_plot_visualize_empirical_cdf_001.png
:alt: X0 CDF
:class: sphx-glr-single-img
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.
.. code-block:: default
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:: /auto_data_analysis/sample_analysis/images/sphx_glr_plot_visualize_empirical_cdf_002.png
:alt: X0 CDF
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.137 seconds)
.. _sphx_glr_download_auto_data_analysis_sample_analysis_plot_visualize_empirical_cdf.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. 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-jupyter
:download:`Download Jupyter notebook: plot_visualize_empirical_cdf.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_