Create a conditional distributionΒΆ

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

\underline{X}|\underline{\Theta}

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

\underline{\Theta}=f(\underline{Y})

[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
XgivenThetaDist = ot.Uniform()
[10]:
# create the distribution
XDist = ot.ConditionalDistribution(XgivenThetaDist, YDist, f)
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)
00.9728112831135585
1-0.6559410049696013
21.0507751769138765
31.2772566044528357
4-0.1016629888293733
[12]:
# draw PDF
XDist.drawPDF()
[12]:
../../_images/examples_probabilistic_modeling_conditional_distribution_8_0.svg