Note
Click here to download the full example code
Create a random vectorΒΆ
The RandomVector object represents the concept of random variable.
In this example we are going to exhibit some of its main methods.
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
dist3d = ot.Normal(3)
X = ot.RandomVector(dist3d)
Get the dimension
X.getDimension()
Out:
3
Get the mean
X.getMean()
Get the covariance
X.getCovariance()
Draw a sample
X.getSample(5)
Extract a single component
X1 = X.getMarginal(1)
X1.getSample(5)
Extract several components
X02 = X.getMarginal([0, 2])
X02.getSample(5)
Total running time of the script: ( 0 minutes 0.002 seconds)