.. 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 Click :ref:`here ` 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 6-10 Abstract -------- Random designs of experiments can be generated from probability distributions. .. GENERATED FROM PYTHON SOURCE LINES 12-19 .. code-block:: default 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) .. GENERATED FROM PYTHON SOURCE LINES 20-21 We create the underlying distribution: a standard 2-dimensional normal distribution. .. GENERATED FROM PYTHON SOURCE LINES 21-24 .. code-block:: default distribution = ot.Normal(2) size = 50 .. GENERATED FROM PYTHON SOURCE LINES 25-29 The Monte Carlo design of experiments ------------------------------------- We build the experiment with the :class:`~openturns.MonteCarloExperiment` class : .. GENERATED FROM PYTHON SOURCE LINES 29-32 .. code-block:: default experiment = ot.MonteCarloExperiment(distribution, size) sample = experiment.generate() .. GENERATED FROM PYTHON SOURCE LINES 33-34 We draw the design of experiments as a :class:`~openturns.Cloud` .. GENERATED FROM PYTHON SOURCE LINES 34-39 .. code-block:: default 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.png :alt: Monte Carlo design :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_create_random_doe_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 40-44 Latin Hypercube Sampling ------------------------ We build the LHS design of experiments with the :class:`~openturns.LHSExperiment` class : .. GENERATED FROM PYTHON SOURCE LINES 44-47 .. code-block:: default experiment = ot.LHSExperiment(distribution, size) sample = experiment.generate() .. GENERATED FROM PYTHON SOURCE LINES 48-49 We draw the LHS design of experiments as a cloud : .. GENERATED FROM PYTHON SOURCE LINES 49-54 .. code-block:: default 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.png :alt: LHS design :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_create_random_doe_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 55-56 Display figures .. GENERATED FROM PYTHON SOURCE LINES 56-57 .. code-block:: default plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.124 seconds) .. _sphx_glr_download_auto_reliability_sensitivity_design_of_experiments_plot_create_random_doe.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. 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-jupyter :download:`Download Jupyter notebook: plot_create_random_doe.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_