.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_reliability_sensitivity/reliability/plot_estimate_probability_adaptive_directional_sampling.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_reliability_plot_estimate_probability_adaptive_directional_sampling.py: Use the Adaptive Directional Stratification Algorithm ===================================================== .. GENERATED FROM PYTHON SOURCE LINES 6-7 In this example we estimate a failure probability with the adaptive directional simulation algorithm provided by the :class:`~openturns.AdaptiveDirectionalStratification` class. .. GENERATED FROM PYTHON SOURCE LINES 9-25 Introduction ------------ The adaptive directional simulation algorithm operates in the standard. It relies on: 1. a *root strategy* to evaluate the nearest failure point along each direction and take the contribution of each direction to the failure event probability into account. The available strategies are: - `RiskyAndFast` - `MediumSafe` - `SafeAndSlow` 2. a *sampling strategy* to choose directions in the standard space. The available strategies are: - `RandomDirection` - `OrthogonalDirection` Let us consider the analytical example of the cantilever beam described :ref:`here `. .. GENERATED FROM PYTHON SOURCE LINES 27-33 .. code-block:: default from openturns.usecases import cantilever_beam import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 34-35 We load the model from the usecases module : .. GENERATED FROM PYTHON SOURCE LINES 35-37 .. code-block:: default cb = cantilever_beam.CantileverBeam() .. GENERATED FROM PYTHON SOURCE LINES 38-39 We load the joint probability distribution of the input parameters : .. GENERATED FROM PYTHON SOURCE LINES 39-41 .. code-block:: default distribution = cb.distribution .. GENERATED FROM PYTHON SOURCE LINES 42-43 We load the model giving the displacement at the end of the beam : .. GENERATED FROM PYTHON SOURCE LINES 43-45 .. code-block:: default model = cb.model .. GENERATED FROM PYTHON SOURCE LINES 46-47 We create the event whose probability we want to estimate. .. GENERATED FROM PYTHON SOURCE LINES 49-53 .. code-block:: default vect = ot.RandomVector(distribution) G = ot.CompositeRandomVector(model, vect) event = ot.ThresholdEvent(G, ot.Greater(), 0.30) .. GENERATED FROM PYTHON SOURCE LINES 54-55 Root finding algorithm. .. GENERATED FROM PYTHON SOURCE LINES 57-60 .. code-block:: default solver = ot.Brent() rootStrategy = ot.MediumSafe(solver) .. GENERATED FROM PYTHON SOURCE LINES 61-62 Direction sampling algorithm. .. GENERATED FROM PYTHON SOURCE LINES 64-66 .. code-block:: default samplingStrategy = ot.RandomDirection() .. GENERATED FROM PYTHON SOURCE LINES 67-68 Create a simulation algorithm. .. GENERATED FROM PYTHON SOURCE LINES 70-77 .. code-block:: default algo = ot.AdaptiveDirectionalStratification( event, rootStrategy, samplingStrategy) algo.setMaximumCoefficientOfVariation(0.1) algo.setMaximumOuterSampling(40000) algo.setConvergenceStrategy(ot.Full()) algo.run() .. GENERATED FROM PYTHON SOURCE LINES 78-79 Retrieve results. .. GENERATED FROM PYTHON SOURCE LINES 81-86 .. code-block:: default result = algo.getResult() probability = result.getProbabilityEstimate() print(result) print('Pf=', probability) print('Iterations=', result.getOuterSampling()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none probabilityEstimate=4.858973e-07 varianceEstimate=1.332228e-15 standard deviation=3.65e-08 coefficient of variation=7.51e-02 confidenceLength(0.95)=1.43e-07 outerSampling=39997 blockSize=1 Pf= 4.85897285169888e-07 Iterations= 39997 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 2.257 seconds) .. _sphx_glr_download_auto_reliability_sensitivity_reliability_plot_estimate_probability_adaptive_directional_sampling.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_estimate_probability_adaptive_directional_sampling.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_estimate_probability_adaptive_directional_sampling.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_