.. 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_optimal_lhs.py:
Optimal LHS designs
===================
This examples show how to generate optimized LHS experiments according to the different criteria.
.. code-block:: default
from __future__ import print_function
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)
**LHS and space filling**
.. code-block:: default
N = 100
# Considering independent Uniform distributions of dimension 3
# Bounds are (-1,1), (0,2) and (0, 0.5)
distribution = ot.ComposedDistribution([ot.Uniform(-1.0, 1.0), ot.Uniform(0.0, 2.0), ot.Uniform(0.0, 0.5)])
# Random LHS
lhs = ot.LHSExperiment(distribution, N)
lhs.setAlwaysShuffle(True) # randomized
design = lhs.generate()
# C2
c2 = ot.SpaceFillingC2().evaluate(design)
# PhiP with default p
phip = ot.SpaceFillingPhiP().evaluate(design)
# mindist
mindist = ot.SpaceFillingMinDist().evaluate(design)
# For p->infinity
phip_inf = ot.SpaceFillingPhiP(100).evaluate(design)
print(phip, mindist, phip_inf)
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
15.722897751576225 0.042216452730087735 15.720769617188896
**Optimized LHS using Monte Carlo**
As with Monte Carlo, user decides of a fixed number of iterations,
but this time this number is part of the temperature profile.
Two profiles are currently provided:
- Linear profile: :math:`T_i = T_0 (1-\frac{1}{n_{iter}})`
- Geometric profile: :math:`T_i = T_O c^i, 0 draw criterion
graph = result.drawHistoryCriterion()
view = viewer.View(graph)
.. image:: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_optimal_lhs_001.png
:alt: C2 criterion history of optimal design
:class: sphx-glr-single-img
Convergence needs to be performed
New algo starting from this design
.. code-block:: default
algo = ot.SimulatedAnnealingLHS(design, distribution, temperatureProfile, space_filling)
design = algo.generate()
plt.show()
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.493 seconds)
.. _sphx_glr_download_auto_reliability_sensitivity_design_of_experiments_plot_optimal_lhs.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_optimal_lhs.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_optimal_lhs.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_