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 48 49 50 51 52 53
|
"""
Create a random design of experiments
=====================================
"""
# %%
# Abstract
# --------
#
# Random designs of experiments can be generated from probability distributions.
# %%
import openturns as ot
import openturns.viewer as otv
# %%
# We create the underlying distribution: a standard 2-dimensional normal distribution.
distribution = ot.Normal(2)
size = 50
# %%
# The Monte Carlo design of experiments
# -------------------------------------
#
# We build the experiment with the :class:`~openturns.MonteCarloExperiment` class :
experiment = ot.MonteCarloExperiment(distribution, size)
sample = experiment.generate()
# %%
# We draw the design of experiments as a :class:`~openturns.Cloud`
graph = ot.Graph("Monte Carlo design", r"$x_1$", r"$x_2$", True, "")
cloud = ot.Cloud(sample, "blue", "fsquare", "")
graph.add(cloud)
view = otv.View(graph)
# %%
# Latin Hypercube Sampling
# ------------------------
#
# We build the LHS design of experiments with the :class:`~openturns.LHSExperiment` class :
experiment = ot.LHSExperiment(distribution, size)
sample = experiment.generate()
# %%
# We draw the LHS design of experiments as a cloud :
graph = ot.Graph("LHS design", r"$x_1$", r"$x_2$", True, "")
cloud = ot.Cloud(sample, "blue", "fsquare", "")
graph.add(cloud)
view = otv.View(graph)
# %%
# Display all figures
otv.View.ShowAll()
|