# Create a conditional distribution¶

In this basic example we are going to build the distribution of the random vector X conditioned by the random variable Theta

with Theta obtained with the random variable Y through a function f

[6]:

from __future__ import print_function
import openturns as ot

[7]:

# create the Y distribution
YDist = ot.Uniform(-1.0, 1.0)

[8]:

# create Theta=f(y)
f = ot.SymbolicFunction(['y'], ['y', '1+y^2'])

[9]:

# create the X|Theta distribution

[10]:

# create the distribution
XDist.setDescription(['X|Theta=f(y)'])
XDist

[10]:


ConditionalDistribution(X with X|Theta~Uniform(Theta), Theta=f(Y), f=[y]->[y,1+y^2], Y~Uniform(a = -1, b = 1))

[11]:

# Get a sample
XDist.getSample(5)

[11]:

 X|Theta=f(y) 0 0.9728112831135585 1 -0.6559410049696013 2 1.0507751769138765 3 1.2772566044528357 4 -0.1016629888293733
[12]:

# draw PDF
XDist.drawPDF()

[12]: