.. 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_2d_gaussian_distribution.py:
Create a 2-d gaussian distribution
==================================
In this example we are going to create a bidimensional gaussian distribution with parameters :math:`\mu = [0.0, 2.2], \sigma = [1.0, 0.6]`.
.. 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)
create the distribution, no correlation
.. code-block:: default
distribution = ot.Normal([0.0, 2.0], [1.0, 0.6], ot.CorrelationMatrix(2))
print(distribution)
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
Normal(mu = [0,2], sigma = [1,0.6], R = [[ 1 0 ]
[ 0 1 ]])
draw a sample
.. code-block:: default
sample = distribution.getSample(10)
print(sample)
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
[ X0 X1 ]
0 : [ -0.533767 2.50205 ]
1 : [ 0.637214 2.74318 ]
2 : [ -0.330867 1.94233 ]
3 : [ 1.90132 2.92378 ]
4 : [ 0.210666 2.00093 ]
5 : [ -2.17162 2.16491 ]
6 : [ 0.670238 1.76749 ]
7 : [ 0.429259 3.81131 ]
8 : [ -1.69802 2.44749 ]
9 : [ -0.238387 2.08961 ]
draw PDF
.. code-block:: default
graph = distribution.drawPDF()
view = viewer.View(graph)
plt.show()
.. image:: /auto_probabilistic_modeling/distributions/images/sphx_glr_plot_2d_gaussian_distribution_001.png
:alt: [X0,X1] iso-PDF
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.128 seconds)
.. _sphx_glr_download_auto_probabilistic_modeling_distributions_plot_2d_gaussian_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_2d_gaussian_distribution.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_2d_gaussian_distribution.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_