Esempio n. 1
0
    idx[0] = x1.index(min(x1))
    idx[1] = x1.index(max(x1))
    idx[2] = x2.index(min(x2))
    idx[3] = x2.index(max(x2))

    labels = ot.Description(sample2D.getSize())
    for i in range(4):
        labels[idx[i]] = str(idx[i])

    position = ot.Description(sample2D.getSize(), "top")
    position[idx[0]] = "right"
    position[idx[1]] = "left"
    position[idx[2]] = "top"
    position[idx[3]] = "bottom"

    text = ot.Text(sample2D, labels)
    text.setColor("red")
    text.setTextPositions(position)

    graph.add(text)
    view = View(graph)
    view.show()

    # CobWeb tests
    size = 100
    dim = 6
    inputSample = ot.Normal(dim).getSample(size)
    inputVar = list(['X' + str(i) for i in range(dim)])
    expression = ''
    for i in range(dim):
        if i > 0:
Esempio n. 2
0
# %%
# We shall represent this curve using a :class:`~openturns.Contour` object.
nx, ny = 15, 15
xx = ot.Box([nx], ot.Interval([0.0], [10.0])).generate()
yy = ot.Box([ny], ot.Interval([-10.0], [10.0])).generate()
inputData = ot.Box([nx, ny], ot.Interval([0.0, -10.0],
                                         [10.0, 10.0])).generate()
outputData = f(inputData)
mycontour = ot.Contour(xx, yy, outputData, [10.0], ["10.0"])
myGraph = ot.Graph("Representation of the failure domain", r"$X_1$", r"$X_2$",
                   True, "")
myGraph.add(mycontour)

# %%
texts = [r" Event : $\mathcal{D} = \{Y \geq 10.0\}$"]
myText = ot.Text([[4.0, 4.0]], texts)
myText.setTextSize(1)
myGraph.add(myText)
view = otv.View(myGraph)

# %%
# We can superimpose the event boundary with the 2D-PDF ot the input variables :
#
mycontour.setColor("black")
mycontour.setLabels(["event"])
graphPDF.add(mycontour)
graphPDF.setLegendPosition("bottomright")
view = otv.View(graphPDF)

# %%
# From the previous figure we observe that in the failure domain the PDF takes small (and even very small) values. Consequently the probability of the failure, the integral :math:`P_f` is also expected to be small. The FORM/SORM methods estimate this kind of integral.
Esempio n. 3
0
# %%
# We create a polygon from these vertices with the :class:`~openturns.Polygon`
# class : that is our domain event. 
myGraph = ot.Graph('Domain event', r'$x_1$', r'$x_2$', True, '', 1.0)
myPolygon = ot.Polygon(data)
myPolygon.setColor('darkgray')
myPolygon.setEdgeColor('darkgray')
myGraph.add(myPolygon)

# Some annotation                                                                             
texts = ot.Description(1)
texts[0] = r'$\mathcal{D} = \{ x=(x_1, x_2) \in \mathbb{R}^2 / x_1+x_2 \in [0,1] \mathrm{~and~} 2x_1 \in [0,1] \}$'


myText = ot.Text(ot.Point([0.25]), ot.Point([0.0]), texts)
myText.setTextSize(1)
myGraph.add(myText)
#view = otv.View(graphStandardSpace)


view = otv.View(myGraph)


# %%
# A simple example
# ----------------
#
# For illustration purpose, consider the integral
#
# .. math::
# %%
# We create a polygon from these vertices with the :class:`~openturns.Polygon`
# class : that is our domain event.
myGraph = ot.Graph('Domain event', r'$x_1$', r'$x_2$', True, '', 1.0)
myPolygon = ot.Polygon(data)
myPolygon.setColor('darkgray')
myPolygon.setEdgeColor('darkgray')
myGraph.add(myPolygon)

# Some annotation
texts = [
    r'$\mathcal{D} = \{ \mathbf{x}=(x_1, x_2) \in \mathbb{R}^2 \; | \; x_1+x_2 \in [0,1] \; \mathrm{and} \; 2x_1 \in [0,1] \}$'
]

myText = ot.Text([0.25], [0.0], texts)
myText.setTextSize(1)
myGraph.add(myText)
view = otv.View(myGraph)

# %%
# An example
# ----------
#
# Consider the integral
#
# .. math::
#
#    P_f = \int_{\mathcal{D}} \mathbf{1}_{\mathcal{D}}(\vect{x}) f_{X_1,X_2}(\vect{x}) d \vect{x}
#
# where :math:`{\mathcal{D}}` is the previous domain event, :math:`\mathbf{1}_{\mathcal{D}}` is the indicator function on the domain and :math:`f_{X_1,X_2}` is the probability density function of the input variable.
Esempio n. 5
0
# Display extrema indices
x1 = [x[0] for x in sample[:, 0]]
x2 = [x[0] for x in sample[:, 1]]
idx = [0] * 4
idx[0] = x1.index(min(x1))
idx[1] = x1.index(max(x1))
idx[2] = x2.index(min(x2))
idx[3] = x2.index(max(x2))

labels = ot.Description(sample.getSize())
for i in range(4):
    labels[idx[i]] = str(idx[i])

position = ot.Description(sample.getSize(), "top")
position[idx[0]] = "right"
position[idx[1]] = "left"
position[idx[2]] = "top"
position[idx[3]] = "bottom"

annotations = ot.Text(sample, labels)
annotations.setColor("red")
annotations.setTextPositions(position)

graph.add(annotations)

fig = plt.figure(figsize=(4, 4))
plt.suptitle("Cloud example")
axis = fig.add_subplot(111)
axis.set_xlim(auto=True)
View(graph, figure=fig, axes=[axis], add_legend=False)