Create a random design of experiments

Abstract

Random designs of experiments can be generated from probability distributions.

from __future__ import print_function
import openturns as ot
import openturns.viewer as viewer
import math as m
from matplotlib import pylab as plt
ot.Log.Show(ot.Log.NONE)

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 MonteCarloExperiment class :

experiment = ot.MonteCarloExperiment(distribution, size)
sample = experiment.generate()

We draw the design of experiments as a Cloud

graph = ot.Graph("Monte Carlo design", r"$x_1$", r"$x_2$", True, "")
cloud = ot.Cloud(sample, "blue", "fsquare", "")
graph.add(cloud)
view = viewer.View(graph)
Monte Carlo design

Latin Hypercube Sampling

We build the LHS design of experiments with the 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 = viewer.View(graph)
LHS design

Display figures

plt.show()

Total running time of the script: ( 0 minutes 0.192 seconds)

Gallery generated by Sphinx-Gallery