Note
Go to the end to download the full example code.
Create a Joint by Conditioning distributionΒΆ
In this example we are going to build the distribution of the random vector:
with conditioned by the random vector
obtained with the random variable
through a function
:
import openturns as ot
import openturns.viewer as viewer
We consider the following case:
with
and
.
We first create the distribution:
YDist = ot.Normal(0.0, 1.0)
Then we create the link function :
f = ot.SymbolicFunction(["y"], ["y", "0.1 + y^2"])
Then, we create the distribution:
XgivenThetaDist = ot.Normal()
At last, we create the distribution of :
XDist = ot.JointByConditioningDistribution(XgivenThetaDist, YDist, f)
XDist.setDescription(["Y", r"$X|\mathbf{\boldsymbol{\Theta}} = f(Y)$"])
XDist
Get a sample:
sample = XDist.getSample(100)
Draw the PDF:
ot.ResourceMap.SetAsString("Contour-DefaultColorMapNorm", "rank")
graph = XDist.drawPDF(sample.getMin(), sample.getMax(), [256] * 2)
graph.setTitle(r"$(Y,X)$ iso-PDF")
cloud = ot.Cloud(sample)
cloud.setColor("red")
cloud.setLegend("sample")
graph.add(cloud)
view = viewer.View(graph)
view.ShowAll()