` to download the full example code
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_auto_probabilistic_modeling_distributions_plot_composed_distribution.py:
Create a composed distribution
==============================
In this example we are going to create a multidimensional distribution described by its marginal distributions and optionally its dependence structure (a particular copula).
.. 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 marginals
.. code-block:: default
marginals = [ot.Normal(), ot.Gumbel()]
create the multivariate distribution, assume no dependency structure
.. code-block:: default
distribution = ot.ComposedDistribution(marginals)
draw PDF
.. code-block:: default
graph = distribution.drawPDF()
view = viewer.View(graph)
.. image:: /auto_probabilistic_modeling/distributions/images/sphx_glr_plot_composed_distribution_001.png
:alt: [X0,X1] iso-PDF
:class: sphx-glr-single-img
create the copula which specifies the dependency structure
.. code-block:: default
R = ot.CorrelationMatrix(2)
R[0, 1] = 0.3
copula = ot.NormalCopula(R)
copula
.. raw:: html
NormalCopula(R = [[ 1 0.3 ]
[ 0.3 1 ]])
create the multivariate distribution with the desired copula
.. code-block:: default
distribution = ot.ComposedDistribution(marginals, copula)
draw PDF
.. code-block:: default
graph = distribution.drawPDF()
view = viewer.View(graph)
plt.show()
.. image:: /auto_probabilistic_modeling/distributions/images/sphx_glr_plot_composed_distribution_002.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.249 seconds)
.. _sphx_glr_download_auto_probabilistic_modeling_distributions_plot_composed_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_composed_distribution.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_composed_distribution.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_