.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_probabilistic_modeling/distributions/plot_conditional_distribution.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_probabilistic_modeling_distributions_plot_conditional_distribution.py: Create a conditional distribution ================================= .. GENERATED FROM PYTHON SOURCE LINES 9-19 In this example we are going to build the distribution of the random vector :math:`\vect{X}` conditioned by the random vector :math:`\vect{\Theta}` .. math:: \vect{X}|\vect{\Theta} with :math:`\vect{\Theta}` obtained with the random variable :math:`Y` through a function :math:`f` .. math:: \vect{\Theta}=f(Y) .. GENERATED FROM PYTHON SOURCE LINES 21-25 .. code-block:: Python import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt .. GENERATED FROM PYTHON SOURCE LINES 26-27 Create the :math:`Y` distribution .. GENERATED FROM PYTHON SOURCE LINES 27-29 .. code-block:: Python YDist = ot.Uniform(-1.0, 1.0) .. GENERATED FROM PYTHON SOURCE LINES 30-31 Create :math:`\vect{\Theta}=f(Y)` .. GENERATED FROM PYTHON SOURCE LINES 31-33 .. code-block:: Python f = ot.SymbolicFunction(["y"], ["y", "1+y^2"]) .. GENERATED FROM PYTHON SOURCE LINES 34-35 Create the :math:`\vect{X}|\vect{\Theta}` distribution .. GENERATED FROM PYTHON SOURCE LINES 35-37 .. code-block:: Python XgivenThetaDist = ot.Uniform() .. GENERATED FROM PYTHON SOURCE LINES 38-39 create the distribution .. GENERATED FROM PYTHON SOURCE LINES 39-43 .. code-block:: Python XDist = ot.DeconditionedDistribution(XgivenThetaDist, YDist, f) XDist.setDescription(["X|Theta=f(y)"]) XDist .. raw:: html
DeconditionedDistribution


.. GENERATED FROM PYTHON SOURCE LINES 44-45 Get a sample .. GENERATED FROM PYTHON SOURCE LINES 45-47 .. code-block:: Python XDist.getSample(5) .. raw:: html
X|Theta=f(y)
01.089899
11.025966
2-0.1632018
30.9276957
41.331287


.. GENERATED FROM PYTHON SOURCE LINES 48-49 Draw PDF .. GENERATED FROM PYTHON SOURCE LINES 49-52 .. code-block:: Python graph = XDist.drawPDF() view = viewer.View(graph) plt.show() .. image-sg:: /auto_probabilistic_modeling/distributions/images/sphx_glr_plot_conditional_distribution_001.png :alt: plot conditional distribution :srcset: /auto_probabilistic_modeling/distributions/images/sphx_glr_plot_conditional_distribution_001.png :class: sphx-glr-single-img .. _sphx_glr_download_auto_probabilistic_modeling_distributions_plot_conditional_distribution.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_conditional_distribution.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_conditional_distribution.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_conditional_distribution.zip `