.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_numerical_methods/optimization/plot_minmax_by_random_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_numerical_methods_optimization_plot_minmax_by_random_design.py: Mix/max search and sensitivity from design ========================================== .. GENERATED FROM PYTHON SOURCE LINES 6-7 In this example we are going to evaluate the min and max values of the output variable of interest from a sample and to evaluate the gradient of the limit state function defining the output variable of interest at a particular point. .. GENERATED FROM PYTHON SOURCE LINES 10-17 .. code-block:: default from __future__ import print_function import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt import math as m ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 18-19 Create the marginal distributions of the parameters .. GENERATED FROM PYTHON SOURCE LINES 19-26 .. code-block:: default dist_E = ot.Beta(0.93, 2.27, 2.8e7, 4.8e7) dist_F = ot.LogNormalMuSigma(30000, 9000, 15000).getDistribution() dist_L = ot.Uniform(250, 260) dist_I = ot.Beta(2.5, 1.5, 3.1e2, 4.5e2) marginals = [dist_E, dist_F, dist_L, dist_I] distribution = ot.ComposedDistribution(marginals) .. GENERATED FROM PYTHON SOURCE LINES 27-28 Sample inputs .. GENERATED FROM PYTHON SOURCE LINES 28-30 .. code-block:: default sampleX = distribution.getSample(100) .. GENERATED FROM PYTHON SOURCE LINES 31-32 Create the model .. GENERATED FROM PYTHON SOURCE LINES 32-34 .. code-block:: default model = ot.SymbolicFunction(['E', 'F', 'L', 'I'], ['F*L^3/(3*E*I)']) .. GENERATED FROM PYTHON SOURCE LINES 35-36 Evaluate outputs .. GENERATED FROM PYTHON SOURCE LINES 36-38 .. code-block:: default sampleY = model(sampleX) .. GENERATED FROM PYTHON SOURCE LINES 39-40 Get min and max .. GENERATED FROM PYTHON SOURCE LINES 40-47 .. code-block:: default minY = sampleY.getMin() minX = sampleX[sampleY.find(minY)] print('min: y=', minY, ' with x=', minX) maxY = sampleY.getMax() maxX = sampleX[sampleY.find(maxY)] print('max: y=', maxY, ' with x=', maxX) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none min: y= [6.35444] with x= [4.36732e+07,19232.1,257.238,393.206] max: y= [29.9854] with x= [3.45218e+07,63587.7,258.04,351.814] .. GENERATED FROM PYTHON SOURCE LINES 48-49 Get sensitivity at min .. GENERATED FROM PYTHON SOURCE LINES 49-50 .. code-block:: default model.gradient(minX) .. raw:: html

[[ -1.455e-07 ]
[ 0.000330408 ]
[ 0.0741076 ]
[ -0.0161606 ]]



.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.007 seconds) .. _sphx_glr_download_auto_numerical_methods_optimization_plot_minmax_by_random_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_minmax_by_random_design.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_minmax_by_random_design.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_