.. 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 :ref:`Go to the end ` 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-19 .. code-block:: Python import openturns as ot ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 20-21 Create model f(x) = x1 + 2*x2 .. GENERATED FROM PYTHON SOURCE LINES 21-32 .. code-block:: Python 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 33-34 Create the event Y > 3 .. GENERATED FROM PYTHON SOURCE LINES 34-37 .. code-block:: Python threshold = 3.0 event = ot.ThresholdEvent(outputVector, ot.Greater(), threshold) .. GENERATED FROM PYTHON SOURCE LINES 38-39 Realization as a Bernoulli .. GENERATED FROM PYTHON SOURCE LINES 39-41 .. code-block:: Python print("realization=", event.getRealization()) .. rst-class:: sphx-glr-script-out .. code-block:: none realization= [0] .. GENERATED FROM PYTHON SOURCE LINES 42-43 Sample of 10 realizations as a Bernoulli .. GENERATED FROM PYTHON SOURCE LINES 43-45 .. code-block:: Python print("sample=", event.getSample(10)) .. rst-class:: sphx-glr-script-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 46-47 Build a standard event based on an event .. GENERATED FROM PYTHON SOURCE LINES 47-48 .. code-block:: Python standardEvent = ot.StandardEvent(event) .. _sphx_glr_download_auto_reliability_sensitivity_reliability_plot_event_manipulation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_event_manipulation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_event_manipulation.py `