.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_reliability_sensitivity/design_of_experiments/plot_create_random_doe.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_reliability_sensitivity_design_of_experiments_plot_create_random_doe.py: Create a random design of experiments ===================================== .. GENERATED FROM PYTHON SOURCE LINES 7-11 Abstract -------- Random designs of experiments can be generated from probability distributions. .. GENERATED FROM PYTHON SOURCE LINES 13-17 .. code-block:: Python import openturns as ot import openturns.viewer as viewer from matplotlib import pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 18-19 We create the underlying distribution: a standard 2-dimensional normal distribution. .. GENERATED FROM PYTHON SOURCE LINES 19-22 .. code-block:: Python distribution = ot.Normal(2) size = 50 .. GENERATED FROM PYTHON SOURCE LINES 23-27 The Monte Carlo design of experiments ------------------------------------- We build the experiment with the :class:`~openturns.MonteCarloExperiment` class : .. GENERATED FROM PYTHON SOURCE LINES 27-30 .. code-block:: Python experiment = ot.MonteCarloExperiment(distribution, size) sample = experiment.generate() .. GENERATED FROM PYTHON SOURCE LINES 31-32 We draw the design of experiments as a :class:`~openturns.Cloud` .. GENERATED FROM PYTHON SOURCE LINES 32-37 .. code-block:: Python 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) .. image-sg:: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_create_random_doe_001.svg :alt: Monte Carlo design :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_create_random_doe_001.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 38-42 Latin Hypercube Sampling ------------------------ We build the LHS design of experiments with the :class:`~openturns.LHSExperiment` class : .. GENERATED FROM PYTHON SOURCE LINES 42-45 .. code-block:: Python experiment = ot.LHSExperiment(distribution, size) sample = experiment.generate() .. GENERATED FROM PYTHON SOURCE LINES 46-47 We draw the LHS design of experiments as a cloud : .. GENERATED FROM PYTHON SOURCE LINES 47-52 .. code-block:: Python 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) .. image-sg:: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_create_random_doe_002.svg :alt: LHS design :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_create_random_doe_002.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 53-54 Display figures .. GENERATED FROM PYTHON SOURCE LINES 54-55 .. code-block:: Python plt.show() .. _sphx_glr_download_auto_reliability_sensitivity_design_of_experiments_plot_create_random_doe.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_create_random_doe.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_create_random_doe.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_create_random_doe.zip `