.. 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_directional_sampling.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_reliability_plot_estimate_probability_directional_sampling.py: Use the Directional Sampling Algorithm ====================================== .. GENERATED FROM PYTHON SOURCE LINES 7-8 In this example we estimate a failure probability with the directional simulation algorithm provided by the :class:`~openturns.DirectionalSampling` class. .. GENERATED FROM PYTHON SOURCE LINES 10-27 Introduction ------------ The directional simulation algorithm operates in the standard space based 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 29-35 .. code-block:: Python from openturns.usecases import cantilever_beam import openturns as ot import openturns.viewer as viewer ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 36-37 We load the model from the usecases module : .. GENERATED FROM PYTHON SOURCE LINES 37-39 .. code-block:: Python cb = cantilever_beam.CantileverBeam() .. GENERATED FROM PYTHON SOURCE LINES 40-41 We load the joint probability distribution of the input parameters : .. GENERATED FROM PYTHON SOURCE LINES 41-43 .. code-block:: Python distribution = cb.distribution .. GENERATED FROM PYTHON SOURCE LINES 44-45 We load the model giving the displacement at the end of the beam : .. GENERATED FROM PYTHON SOURCE LINES 45-47 .. code-block:: Python model = cb.model .. GENERATED FROM PYTHON SOURCE LINES 48-49 We create the event whose probability we want to estimate. .. GENERATED FROM PYTHON SOURCE LINES 51-55 .. code-block:: Python vect = ot.RandomVector(distribution) G = ot.CompositeRandomVector(model, vect) event = ot.ThresholdEvent(G, ot.Greater(), 0.30) .. GENERATED FROM PYTHON SOURCE LINES 56-57 Root finding algorithm. .. GENERATED FROM PYTHON SOURCE LINES 59-62 .. code-block:: Python solver = ot.Brent() rootStrategy = ot.MediumSafe(solver) .. GENERATED FROM PYTHON SOURCE LINES 63-64 Direction sampling algorithm. .. GENERATED FROM PYTHON SOURCE LINES 66-68 .. code-block:: Python samplingStrategy = ot.OrthogonalDirection() .. GENERATED FROM PYTHON SOURCE LINES 69-70 Create a simulation algorithm. .. GENERATED FROM PYTHON SOURCE LINES 72-78 .. code-block:: Python algo = ot.DirectionalSampling(event, rootStrategy, samplingStrategy) algo.setMaximumCoefficientOfVariation(0.1) algo.setMaximumOuterSampling(40000) algo.setConvergenceStrategy(ot.Full()) algo.run() .. GENERATED FROM PYTHON SOURCE LINES 79-80 Retrieve results. .. GENERATED FROM PYTHON SOURCE LINES 82-86 .. code-block:: Python result = algo.getResult() probability = result.getProbabilityEstimate() print("Pf=", probability) .. rst-class:: sphx-glr-script-out .. code-block:: none Pf= 5.101278436849363e-07 .. GENERATED FROM PYTHON SOURCE LINES 87-89 We can observe the convergence history with the `drawProbabilityConvergence` method. .. GENERATED FROM PYTHON SOURCE LINES 89-92 .. code-block:: Python graph = algo.drawProbabilityConvergence() graph.setLogScale(ot.GraphImplementation.LOGX) view = viewer.View(graph) .. image-sg:: /auto_reliability_sensitivity/reliability/images/sphx_glr_plot_estimate_probability_directional_sampling_001.png :alt: DirectionalSampling convergence graph at level 0.95 :srcset: /auto_reliability_sensitivity/reliability/images/sphx_glr_plot_estimate_probability_directional_sampling_001.png :class: sphx-glr-single-img .. _sphx_glr_download_auto_reliability_sensitivity_reliability_plot_estimate_probability_directional_sampling.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_estimate_probability_directional_sampling.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_estimate_probability_directional_sampling.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_estimate_probability_directional_sampling.zip `