.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_probabilistic_modeling/random_vectors/plot_random_vector_manipulation.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_random_vectors_plot_random_vector_manipulation.py: Create a random vector ====================== .. GENERATED FROM PYTHON SOURCE LINES 6-9 The RandomVector object represents the concept of random variable. In this example we are going to exhibit some of its main methods. .. GENERATED FROM PYTHON SOURCE LINES 11-17 .. code-block:: default 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) .. GENERATED FROM PYTHON SOURCE LINES 18-19 Create a random vector .. GENERATED FROM PYTHON SOURCE LINES 19-22 .. code-block:: default dist3d = ot.Normal(3) X = ot.RandomVector(dist3d) .. GENERATED FROM PYTHON SOURCE LINES 23-24 Get the dimension .. GENERATED FROM PYTHON SOURCE LINES 24-26 .. code-block:: default X.getDimension() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 3 .. GENERATED FROM PYTHON SOURCE LINES 27-28 Get the mean .. GENERATED FROM PYTHON SOURCE LINES 28-30 .. code-block:: default X.getMean() .. raw:: html

[0,0,0]



.. GENERATED FROM PYTHON SOURCE LINES 31-32 Get the covariance .. GENERATED FROM PYTHON SOURCE LINES 32-34 .. code-block:: default X.getCovariance() .. raw:: html

[[ 1 0 0 ]
[ 0 1 0 ]
[ 0 0 1 ]]



.. GENERATED FROM PYTHON SOURCE LINES 35-36 Draw a sample .. GENERATED FROM PYTHON SOURCE LINES 36-38 .. code-block:: default X.getSample(5) .. raw:: html
X0X1X2
00.3534472-0.2187709-0.8883468
11.3021081.138971.554364
20.48937730.042574421.501532
3-1.147-0.7282897-1.07746
4-1.269175-0.4687614-0.8110714


.. GENERATED FROM PYTHON SOURCE LINES 39-40 Extract a single component .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: default X1 = X.getMarginal(1) X1.getSample(5) .. raw:: html
X1
01.13703
1-0.04030962
21.55857
30.7398424
40.09927194


.. GENERATED FROM PYTHON SOURCE LINES 44-45 Extract several components .. GENERATED FROM PYTHON SOURCE LINES 45-47 .. code-block:: default X02 = X.getMarginal([0, 2]) X02.getSample(5) .. raw:: html
X0X2
00.6119656-0.3669958
11.4285-1.908112
22.113194-0.6656038
3-0.11656161.078081
4-0.5657817-0.6800565


.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.002 seconds) .. _sphx_glr_download_auto_probabilistic_modeling_random_vectors_plot_random_vector_manipulation.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_random_vector_manipulation.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_random_vector_manipulation.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_