示例#1
0
# %%
# Define the underlying random vector.

# %%
dim = 2
R = ot.CorrelationMatrix(dim)
distribution = ot.Normal([2.0, 3.0], [0.5, 2.0], R)
rv = ot.RandomVector(distribution)

# %%
# Define the structure of the design of experiments.

# %%
levels = [1.0, 2.0, 3.0]
experiment = ot.Axial(dim, levels)
sample = experiment.generate()

# %%
# Scale the design proportionnally to the standard deviation of each component.

# %%
covariance = rv.getCovariance()
scaling = [m.sqrt(covariance[i, i]) for i in range(dim)]
print('scaling=', scaling)
sample *= scaling

# %%
# Center the design around the mean point of the distribution.

# %%
import openturns as ot
from matplotlib import pyplot as plt
from openturns.viewer import View

# Generate sample with the given plane
center = [0.5, 1.5]
levels = [4, 8, 16]

myPlane = ot.Axial(center, levels)
sample = myPlane.generate()

# Create the graph
graph = ot.Graph("", "x1", "x2", True, "")
cloud = ot.Cloud(sample, "blue", "fsquare", "")
graph.add(cloud)

# Draw the graph
fig = plt.figure(figsize=(4, 4))
plt.suptitle(sample.getName())
axis = fig.add_subplot(111)
View(graph, figure=fig, axes=[axis], add_legend=False, square_axes=True)
axis.set_xlim(auto=True)
示例#3
0
# %%
def drawBidimensionalSample(sample, title):
    n = sample.getSize()
    graph = ot.Graph("%s, size=%d" % (title, n), "X1", "X2", True, '')
    cloud = ot.Cloud(sample)
    graph.add(cloud)
    return graph


# %%
# Axial design
# ------------

# %%
levels = [1.0, 1.5, 3.0]
experiment = ot.Axial(2, levels)
sample = experiment.generate()
graph = drawBidimensionalSample(sample, "Axial")
view = viewer.View(graph)

# %%
# Scale and to get desired location.

# %%
sample *= 2.0
sample += [5.0, 8.0]
graph = drawBidimensionalSample(sample, "Axial")
view = viewer.View(graph)

# %%
# Factorial design
示例#4
0
import openturns as ot
from openturns.viewer import View

d = ot.Axial([1.5, 2.5, 3.5], [1, 2, 3])
s = d.generate()
s.setDescription(["X1", "X2", "X3"])
g = ot.Graph()
g.setTitle("Axial experiment")
g.setGridColor("black")
p = ot.Pairs(s)
g.add(p)
View(g)