.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_subset_inverse_sampling_R_S.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_examples_plot_subset_inverse_sampling_R_S.py: Subset inverse sampling on an R-S model ======================================= .. GENERATED FROM PYTHON SOURCE LINES 7-30 This example demonstrates :class:`~otrobopt.SubsetInverseSampling` on a simple Resistance-Stress (R-S) model. The limit state function is: .. math:: G(\mathbf{U}) = U_1 - U_2 where :math:`U_1 \sim \mathcal{N}(7, 1)` represents the resistance and :math:`U_2 \sim \mathcal{N}(2, 1)` represents the stress. Failure occurs when :math:`G < 0`. The subset inverse simulation algorithm estimates the threshold value :math:`q` such that: .. math:: \mathbb{P}(G(\mathbf{U}) \leq q) = p_t where :math:`p_t` is a target probability. This is the inverse problem: instead of computing the probability for a given threshold, we find the threshold for a given probability. .. GENERATED FROM PYTHON SOURCE LINES 32-37 .. code-block:: Python import openturns as ot import otrobopt ot.RandomGenerator.SetSeed(0) .. GENERATED FROM PYTHON SOURCE LINES 38-39 Define the limit state function and the probabilistic model. .. GENERATED FROM PYTHON SOURCE LINES 39-52 .. code-block:: Python limitState = ot.SymbolicFunction(['u1', 'u2'], ['u1 - u2']) dim = limitState.getInputDimension() mean = [7.0, 2.0] sigma = [1.0, 1.0] R = ot.IdentityMatrix(dim) distribution = ot.Normal(mean, sigma, R) # Build the event vect = ot.RandomVector(distribution) output = ot.CompositeRandomVector(limitState, vect) event = ot.ThresholdEvent(output, ot.Less(), 0.0) .. GENERATED FROM PYTHON SOURCE LINES 53-55 Run the subset inverse sampling algorithm for a target probability :math:`p_t = 2 \times 10^{-4}`. .. GENERATED FROM PYTHON SOURCE LINES 55-61 .. code-block:: Python targetProbability = 0.0002 algo = otrobopt.SubsetInverseSampling(event, targetProbability) algo.setMaximumOuterSampling(10000) algo.run() .. GENERATED FROM PYTHON SOURCE LINES 62-63 Retrieve and display the results. .. GENERATED FROM PYTHON SOURCE LINES 63-74 .. code-block:: Python result = algo.getResult() pf = result.getProbabilityEstimate() threshold = algo.getThresholdPerStep()[-1] threshold_cl = algo.getThresholdConfidenceLength(0.90) print('Target probability =', targetProbability) print('Estimated probability =', pf) print('Threshold at target =', threshold) print('Threshold confidence length (90%) =', threshold_cl) print('Number of steps =', algo.getNumberOfSteps()) print('Coefficient of variation =', result.getCoefficientOfVariation()) .. rst-class:: sphx-glr-script-out .. code-block:: none Target probability = 0.0002 Estimated probability = 0.00020000000000000025 Threshold at target = 0.020271550198725088 Threshold confidence length (90%) = 0.02133651921248595 Number of steps = 4 Coefficient of variation = 0.08323641030222287 .. _sphx_glr_download_auto_examples_plot_subset_inverse_sampling_R_S.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_subset_inverse_sampling_R_S.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_subset_inverse_sampling_R_S.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_subset_inverse_sampling_R_S.zip `