.. 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_mixed_design.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_mixed_design.py: Create mixed deterministic and probabilistic designs of experiments =================================================================== .. GENERATED FROM PYTHON SOURCE LINES 6-9 In this example we build a mixed deterministic and probabilistic design of experiments in which levels are defined from the probabilistic distribution of the input random vector. More precisely, we show how to create an `Axial` design of experiments whose points are updated so that they match the mean and variance of the distribution. The example here is an axial design of experiments where levels are proportional to the standard deviation of each component of the random input vector, and centered on the mean vector of the random input vector. .. GENERATED FROM PYTHON SOURCE LINES 12-18 .. code-block:: default import openturns as ot import math as m import openturns.viewer as viewer from matplotlib import pylab as plt ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 19-20 Define the underlying random vector. .. GENERATED FROM PYTHON SOURCE LINES 22-27 .. code-block:: default dim = 2 R = ot.CorrelationMatrix(dim) distribution = ot.Normal([2.0, 3.0], [0.5, 2.0], R) rv = ot.RandomVector(distribution) .. GENERATED FROM PYTHON SOURCE LINES 28-29 Define the structure of the design of experiments. .. GENERATED FROM PYTHON SOURCE LINES 31-35 .. code-block:: default levels = [1.0, 2.0, 3.0] experiment = ot.Axial(dim, levels) sample = experiment.generate() .. GENERATED FROM PYTHON SOURCE LINES 36-37 Scale the design proportionnally to the standard deviation of each component. .. GENERATED FROM PYTHON SOURCE LINES 39-44 .. code-block:: default covariance = rv.getCovariance() scaling = [m.sqrt(covariance[i, i]) for i in range(dim)] print('scaling=', scaling) sample *= scaling .. rst-class:: sphx-glr-script-out Out: .. code-block:: none scaling= [0.5, 2.0] .. GENERATED FROM PYTHON SOURCE LINES 45-46 Center the design around the mean point of the distribution. .. GENERATED FROM PYTHON SOURCE LINES 48-52 .. code-block:: default center = rv.getMean() print('center=', center) sample += center .. rst-class:: sphx-glr-script-out Out: .. code-block:: none center= [2,3] .. GENERATED FROM PYTHON SOURCE LINES 53-54 Draw the design as well as the distribution iso-values. .. GENERATED FROM PYTHON SOURCE LINES 56-63 .. code-block:: default graph = distribution.drawPDF() doe = ot.Cloud(sample) doe.setColor('red') doe.setLegend('design') graph.add(doe) view = viewer.View(graph) plt.show() .. image-sg:: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_mixed_design_001.png :alt: [X0,X1] iso-PDF :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_mixed_design_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.112 seconds) .. _sphx_glr_download_auto_reliability_sensitivity_design_of_experiments_plot_mixed_design.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_mixed_design.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_mixed_design.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_