Note
Click here to download the full example code
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.
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
dist2d = ot.Normal(2)
X = ot.RandomVector(dist2d)
Create the function
f = ot.SymbolicFunction(['x1', 'x2'], ['x1 + x2', 'x1*x2'])
f
[x1,x2]->[x1 + x2,x1*x2]
Create the composite random vector
Y = ot.CompositeRandomVector(f, X)
Y.getSample(5)
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 |
Total running time of the script: ( 0 minutes 0.002 seconds)