.. 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_probabilistic_modeling_distributions_plot_geometric_distribution.py:
Create a geometric distribution
===============================
In this example we are going to create a geometric distribution with parameter :math:`p = 0.7`.
.. 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)
distribution = ot.Geometric(0.7)
print(distribution)
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
Geometric(p = 0.7)
.. code-block:: default
sample = distribution.getSample(10)
print(sample)
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
[ X0 ]
0 : [ 3 ]
1 : [ 2 ]
2 : [ 1 ]
3 : [ 2 ]
4 : [ 3 ]
5 : [ 1 ]
6 : [ 1 ]
7 : [ 3 ]
8 : [ 3 ]
9 : [ 1 ]
.. code-block:: default
graph = distribution.drawCDF()
view = viewer.View(graph)
plt.show()
.. image:: /auto_probabilistic_modeling/distributions/images/sphx_glr_plot_geometric_distribution_001.png
:alt: X0 CDF
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.068 seconds)
.. _sphx_glr_download_auto_probabilistic_modeling_distributions_plot_geometric_distribution.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_geometric_distribution.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_geometric_distribution.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_