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

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

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

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

In [1]:
from __future__ import print_function
import openturns as ot
In [2]:
# create the Y distribution
YDist = ot.Normal(0.0, 1.0)
In [3]:
# create Theta=f(y)
f = ot.SymbolicFunction(['y'], ['y', '0.1+y^2'])
In [4]:
# create the X|Theta distribution
XgivenThetaDist = ot.Normal()
In [5]:
# create the distribution
XDist = ot.ConditionalDistribution(XgivenThetaDist, YDist, f)
XDist.setDescription(['X|Theta=f(y)'])
XDist
Out[5]:

ConditionalDistribution(X with X|Theta~Normal(Theta), Theta=f(Y), f=[y]->[y,0.1+y^2], Y~Normal(mu = 0, sigma = 1))

In [6]:
# Get a sample
XDist.getSample(5)
Out[6]:
X|Theta=f(y)
00.01321520022795053
1-0.08617346047947638
2-0.48072622003836907
3-0.03014558046921334
41.4112318958250651
In [7]:
# draw PDF
XDist.drawPDF()
Out[7]:
../../_images/examples_probabilistic_modeling_conditional_distribution_8_0.svg