.. 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_design_of_experiments.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_design_of_experiments.py: Various design of experiments in OpenTURNS ========================================== .. GENERATED FROM PYTHON SOURCE LINES 6-7 The goal of this example is to present several design of experiments available in OpenTURNS. .. GENERATED FROM PYTHON SOURCE LINES 10-12 Distribution ------------ .. GENERATED FROM PYTHON SOURCE LINES 14-19 .. code-block:: default import openturns as ot import openturns.viewer as otv ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 20-22 Monte-Carlo sampling in 2D -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 24-29 .. code-block:: default dim = 2 X = [ot.Uniform()] * dim distribution = ot.ComposedDistribution(X) bounds = distribution.getRange() .. GENERATED FROM PYTHON SOURCE LINES 30-33 .. code-block:: default sampleSize = 10 sample = distribution.getSample(sampleSize) .. GENERATED FROM PYTHON SOURCE LINES 34-36 .. code-block:: default fig = otv.PlotDesign(sample, bounds) .. image-sg:: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_001.png :alt: plot design of experiments :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 37-38 We see that there a empty zones in the input space. .. GENERATED FROM PYTHON SOURCE LINES 40-42 Monte-Carlo sampling in 3D -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 44-49 .. code-block:: default dim = 3 X = [ot.Uniform()] * dim distribution = ot.ComposedDistribution(X) bounds = distribution.getRange() .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: default sampleSize = 10 sample = distribution.getSample(sampleSize) .. GENERATED FROM PYTHON SOURCE LINES 54-57 .. code-block:: default fig = otv.PlotDesign(sample, bounds) fig.set_size_inches(10, 10) .. image-sg:: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_002.png :alt: plot design of experiments :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 58-60 Latin Hypercube Sampling ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 62-67 .. code-block:: default distribution = ot.ComposedDistribution([ot.Uniform()] * 3) samplesize = 5 experiment = ot.LHSExperiment(distribution, samplesize, False, False) sample = experiment.generate() .. GENERATED FROM PYTHON SOURCE LINES 68-69 In order to see the LHS property, we need to set the bounds. .. GENERATED FROM PYTHON SOURCE LINES 71-73 .. code-block:: default bounds = distribution.getRange() .. GENERATED FROM PYTHON SOURCE LINES 74-77 .. code-block:: default fig = otv.PlotDesign(sample, bounds) fig.set_size_inches(10, 10) .. image-sg:: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_003.png :alt: plot design of experiments :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 78-79 We see that each column or row exactly contains one single point. This shows that a LHS design of experimens has good 1D projection properties, and, hence, is a good candidate for a space filling design. .. GENERATED FROM PYTHON SOURCE LINES 81-83 Optimized LHS ------------- .. GENERATED FROM PYTHON SOURCE LINES 85-88 .. code-block:: default distribution = ot.ComposedDistribution([ot.Uniform()] * 3) samplesize = 10 .. GENERATED FROM PYTHON SOURCE LINES 89-91 .. code-block:: default bounds = distribution.getRange() .. GENERATED FROM PYTHON SOURCE LINES 92-100 .. code-block:: default lhs = ot.LHSExperiment(distribution, samplesize) lhs.setAlwaysShuffle(True) # randomized space_filling = ot.SpaceFillingC2() temperatureProfile = ot.GeometricProfile(10.0, 0.95, 1000) algo = ot.SimulatedAnnealingLHS(lhs, space_filling, temperatureProfile) # optimal design sample = algo.generate() .. GENERATED FROM PYTHON SOURCE LINES 101-104 .. code-block:: default fig = otv.PlotDesign(sample, bounds) fig.set_size_inches(10, 10) .. image-sg:: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_004.png :alt: plot design of experiments :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 105-106 We see that this LHS is optimized in the sense that it fills the space more evenly than a non-optimized does in general. .. GENERATED FROM PYTHON SOURCE LINES 108-110 Sobol' low discrepancy sequence ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 112-116 .. code-block:: default dim = 2 distribution = ot.ComposedDistribution([ot.Uniform()] * dim) bounds = distribution.getRange() .. GENERATED FROM PYTHON SOURCE LINES 117-119 .. code-block:: default sequence = ot.SobolSequence(dim) .. GENERATED FROM PYTHON SOURCE LINES 120-124 .. code-block:: default samplesize = 2**5 # Sobol' sequences are in base 2 experiment = ot.LowDiscrepancyExperiment(sequence, distribution, samplesize, False) sample = experiment.generate() .. GENERATED FROM PYTHON SOURCE LINES 125-127 .. code-block:: default samplesize .. rst-class:: sphx-glr-script-out .. code-block:: none 32 .. GENERATED FROM PYTHON SOURCE LINES 128-132 .. code-block:: default subdivisions = [2**2, 2**1] fig = otv.PlotDesign(sample, bounds, subdivisions) fig.set_size_inches(6, 6) .. image-sg:: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_005.png :alt: plot design of experiments :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 133-134 We have elementary intervals in 2 dimensions, each having a volume equal to 1/8. Since there are 32 points, the Sobol' sequence is so that each elementary interval contains exactly 32/8 = 4 points. Notice that each elementary interval is closed on the left (or bottom) and open on the right (or top). .. GENERATED FROM PYTHON SOURCE LINES 136-138 Halton low discrepancy sequence ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 140-144 .. code-block:: default dim = 2 distribution = ot.ComposedDistribution([ot.Uniform()] * dim) bounds = distribution.getRange() .. GENERATED FROM PYTHON SOURCE LINES 145-147 .. code-block:: default sequence = ot.HaltonSequence(dim) .. GENERATED FROM PYTHON SOURCE LINES 148-149 Halton sequence uses prime numbers 2 and 3 in two dimensions. .. GENERATED FROM PYTHON SOURCE LINES 149-153 .. code-block:: default samplesize = 2**2 * 3**2 experiment = ot.LowDiscrepancyExperiment(sequence, distribution, samplesize, False) sample = experiment.generate() .. GENERATED FROM PYTHON SOURCE LINES 154-156 .. code-block:: default samplesize .. rst-class:: sphx-glr-script-out .. code-block:: none 36 .. GENERATED FROM PYTHON SOURCE LINES 157-161 .. code-block:: default subdivisions = [2**2, 3] fig = otv.PlotDesign(sample, bounds, subdivisions) fig.set_size_inches(6, 6) .. image-sg:: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_006.png :alt: plot design of experiments :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_design_of_experiments_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 162-163 We have elementary intervals in 2 dimensions, each having a volume equal to 1/12. Since there are 36 points, the Halton sequence is so that each elementary interval contains exactly 36/12 = 3 points. Notice that each elementary interval is closed on the left (or bottom) and open on the right (or top). .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.308 seconds) .. _sphx_glr_download_auto_reliability_sensitivity_design_of_experiments_plot_design_of_experiments.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_design_of_experiments.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_design_of_experiments.ipynb `