Create a conditional distributionΒΆ

In this example we are going to build the distribution of the random vector \vect{X} conditioned by the random vector \vect{\Theta}

\vect{X}|\vect{\Theta}

with \vect{\Theta} obtained with the random variable Y through a function f

\vect{\Theta}=f(Y)

import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt

Create the Y distribution

YDist = ot.Uniform(-1.0, 1.0)

Create \vect{\Theta}=f(Y)

f = ot.SymbolicFunction(["y"], ["y", "1+y^2"])

Create the \vect{X}|\vect{\Theta} distribution

XgivenThetaDist = ot.Uniform()

create the distribution

XDist = ot.DeconditionedDistribution(XgivenThetaDist, YDist, f)
XDist.setDescription(["X|Theta=f(y)"])
XDist
DeconditionedDistribution
  • name=DeconditionedDistribution
  • dimension=1
  • weight=1
  • range=[-0.999956, 1.99991]
  • description=[X|Theta=f(y)]
  • isParallel=true
  • isCopula=false


Get a sample

XDist.getSample(5)
X|Theta=f(y)
01.089899
11.025966
2-0.1632018
30.9276957
41.331287


Draw PDF

graph = XDist.drawPDF()
view = viewer.View(graph)
plt.show()
plot conditional distribution