Composite random vectorΒΆ
In this example we are going to create a random variable which realizations are the images of the realizations of another random vector by a function.
[13]:
from __future__ import print_function
import openturns as ot
import math as m
[14]:
# Create a random vector based on a distribution
dist2d = ot.Normal(2)
X = ot.RandomVector(dist2d)
[15]:
# Create the function
f = ot.SymbolicFunction(['x1', 'x2'], ['x1 + x2', 'x1*x2'])
f
[15]:
[x1,x2]->[x1 + x2,x1*x2]
[21]:
# Create the composite random vector
Y = ot.CompositeRandomVector(f, X)
[22]:
Y.getSample(5)
[22]:
y0 | y1 | |
---|---|---|
0 | 0.6340067547705874 | -1.738141317991343 |
1 | 0.860261107301864 | -0.4291467493292659 |
2 | -2.1455645614220247 | 1.0633942511691827 |
3 | -0.7883451164543616 | -0.0922805136143649 |
4 | 1.2403961348448758 | 0.3031904202688173 |