.. 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_composite_random_vector.py:
Composite random vector
=======================
In this example we are going to create a random variable :math:`\underline{Y}` which realizations are the images of the realizations of another random vector :math:`\underline{X}` by a function.
.. math::
\underline{Y} = f(\underline{X})
.. code-block:: default
from __future__ import print_function
import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt
import math as m
ot.Log.Show(ot.Log.NONE)
Create a random vector based on a distribution
.. code-block:: default
dist2d = ot.Normal(2)
X = ot.RandomVector(dist2d)
Create the function
.. code-block:: default
f = ot.SymbolicFunction(['x1', 'x2'], ['x1 + x2', 'x1*x2'])
f
.. raw:: html
[x1,x2]->[x1 + x2,x1*x2]
Create the composite random vector
.. code-block:: default
Y = ot.CompositeRandomVector(f, X)
.. code-block:: default
Y.getSample(5)
.. raw:: html
| y0 | y1 |
0 | -0.2864335 | -0.4336809 |
1 | 1.617266 | -0.03661119 |
2 | 0.8772776 | -0.9895433 |
3 | 3.949424 | 3.633858 |
4 | -3.529936 | 3.078517 |
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.002 seconds)
.. _sphx_glr_download_auto_probabilistic_modeling_distributions_plot_composite_random_vector.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_composite_random_vector.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_composite_random_vector.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_