.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_probabilistic_modeling/distributions/plot_bayes_distribution.py" .. LINE NUMBERS ARE GIVEN BELOW. .. 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_bayes_distribution.py: Create a Bayes distribution =========================== .. GENERATED FROM PYTHON SOURCE LINES 6-16 In this example we are going to build the distribution of the random vector .. math:: ( \underline{X}|\underline{\Theta}, \underline{Y}) with X conditioned by the random variable Theta obtained with the random variable Y through a function f .. math:: \underline{\Theta}=f(\underline{Y}) .. GENERATED FROM PYTHON SOURCE LINES 18-23 .. code-block:: default import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 24-25 create the Y distribution .. GENERATED FROM PYTHON SOURCE LINES 25-27 .. code-block:: default YDist = ot.Uniform(-1.0, 1.0) .. GENERATED FROM PYTHON SOURCE LINES 28-29 create Theta=f(y) .. GENERATED FROM PYTHON SOURCE LINES 29-31 .. code-block:: default f = ot.SymbolicFunction(['y'], ['y', '1 + y']) .. GENERATED FROM PYTHON SOURCE LINES 32-33 create the X|Theta distribution .. GENERATED FROM PYTHON SOURCE LINES 33-35 .. code-block:: default XgivenThetaDist = ot.Uniform() .. GENERATED FROM PYTHON SOURCE LINES 36-37 create the distribution .. GENERATED FROM PYTHON SOURCE LINES 37-41 .. code-block:: default XDist = ot.BayesDistribution(XgivenThetaDist, YDist, f) XDist.setDescription(['X|Theta=f(y)', 'y']) XDist .. raw:: html

BayesDistribution(X, Y with X|Theta~Uniform(Theta), Theta=f(Y), f=[y]->[y,1 + y], Y~Uniform(a = -1, b = 1))



.. GENERATED FROM PYTHON SOURCE LINES 42-43 Get a sample .. GENERATED FROM PYTHON SOURCE LINES 43-45 .. code-block:: default sample = XDist.getSample(100) .. GENERATED FROM PYTHON SOURCE LINES 46-47 draw PDF .. GENERATED FROM PYTHON SOURCE LINES 47-54 .. code-block:: default graph = XDist.drawPDF() cloud = ot.Cloud(sample) cloud.setColor('red') cloud.setLegend('sample') graph.add(cloud) view = viewer.View(graph) plt.show() .. image-sg:: /auto_probabilistic_modeling/distributions/images/sphx_glr_plot_bayes_distribution_001.png :alt: [X|Theta=f(y),y] iso-PDF :srcset: /auto_probabilistic_modeling/distributions/images/sphx_glr_plot_bayes_distribution_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none /home/devel/project/build/python/src/site-packages/openturns/viewer.py:442: UserWarning: No contour levels were found within the data range. contourset = self._ax[0].contour(X, Y, Z, **contour_kw) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.193 seconds) .. _sphx_glr_download_auto_probabilistic_modeling_distributions_plot_bayes_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_bayes_distribution.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_bayes_distribution.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_