File: plot_minmax_by_random_design.py

package info (click to toggle)
openturns 1.26-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,708 kB
  • sloc: cpp: 261,605; python: 67,030; ansic: 4,378; javascript: 406; sh: 185; xml: 164; makefile: 101
file content (47 lines) | stat: -rw-r--r-- 1,274 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Mix/max search and sensitivity from design
==========================================
"""

# %%
#
# In this example, we are going to evaluate the minimum and maximum values of the output variable of interest from a sample
# and to evaluate the gradient of the limit-state function defining the output variable of interest at a particular point.

# %%
import openturns as ot


# %%
# Create the marginal distributions of the parameters.
dist_E = ot.Beta(0.93, 2.27, 2.8e7, 4.8e7)
dist_F = ot.LogNormalMuSigma(30000, 9000, 15000).getDistribution()
dist_L = ot.Uniform(250, 260)
dist_I = ot.Beta(2.5, 1.5, 3.1e2, 4.5e2)
marginals = [dist_E, dist_F, dist_L, dist_I]
distribution = ot.JointDistribution(marginals)

# %%
# Sample the inputs.
sampleX = distribution.getSample(100)

# %%
# Create the model.
model = ot.SymbolicFunction(["E", "F", "L", "I"], ["F*L^3/(3*E*I)"])

# %%
# Evaluate the outputs.
sampleY = model(sampleX)

# %%
# Get minimum and maximum values of both inputs and output variables.
minY = sampleY.getMin()
minX = sampleX[sampleY.find(minY)]
print("min: y=", minY, " with x=", minX)
maxY = sampleY.getMax()
maxX = sampleX[sampleY.find(maxY)]
print("max: y=", maxY, " with x=", maxX)

# %%
# Get sensitivity at minimum input values.
model.gradient(minX)