.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_reliability_sensitivity/reliability/plot_event_manipulation.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_event_manipulation.py: Simulate an Event ================= .. GENERATED FROM PYTHON SOURCE LINES 6-13 In this example we are going to define an Event from a scalar variable :math:`Y` in the form: .. math:: Y > T with :math:`T` a scalar threshold .. GENERATED FROM PYTHON SOURCE LINES 15-20 .. code-block:: default 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 21-22 Create model f(x) = x1 + 2*x2 .. GENERATED FROM PYTHON SOURCE LINES 22-33 .. code-block:: default model = ot.SymbolicFunction(['x1', 'x2'], ['x1+2*x2']) # Create the input distribution and random vector X inputDist = ot.Normal(2) inputDist.setDescription(['X1', 'X2']) inputVector = ot.RandomVector(inputDist) # Create the output random vector Y=f(X) outputVector = ot.CompositeRandomVector(model, inputVector) .. GENERATED FROM PYTHON SOURCE LINES 34-35 Create the event Y > 3 .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: default threshold = 3.0 event = ot.ThresholdEvent(outputVector, ot.Greater(), threshold) .. GENERATED FROM PYTHON SOURCE LINES 39-40 Realization as a Bernoulli .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: default print('realization=', event.getRealization()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none realization= [0] .. GENERATED FROM PYTHON SOURCE LINES 43-44 Sample of 10 realizations as a Bernoulli .. GENERATED FROM PYTHON SOURCE LINES 44-46 .. code-block:: default print('sample=', event.getSample(10)) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none sample= [ y0 ] 0 : [ 0 ] 1 : [ 0 ] 2 : [ 0 ] 3 : [ 0 ] 4 : [ 0 ] 5 : [ 0 ] 6 : [ 0 ] 7 : [ 0 ] 8 : [ 0 ] 9 : [ 0 ] .. GENERATED FROM PYTHON SOURCE LINES 47-48 Build a standard event based on an event .. GENERATED FROM PYTHON SOURCE LINES 48-49 .. code-block:: default standardEvent = ot.StandardEvent(event) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.003 seconds) .. _sphx_glr_download_auto_reliability_sensitivity_reliability_plot_event_manipulation.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_event_manipulation.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_event_manipulation.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_