.. 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: Event manipulation ================== 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 .. code-block:: default from __future__ import print_function import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt ot.Log.Show(ot.Log.NONE) Create model f(x) = x1 + 2*x2 .. 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) Create the event Y > 3 .. code-block:: default threshold = 3.0 event = ot.ThresholdEvent(outputVector, ot.Greater(), threshold) Realization as a Bernoulli .. code-block:: default print('realization=' , event.getRealization()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none realization= [0] Sample of 10 realizations as a Bernoulli .. 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 : [ 1 ] 4 : [ 0 ] 5 : [ 0 ] 6 : [ 0 ] 7 : [ 0 ] 8 : [ 0 ] 9 : [ 0 ] Build a standard event based on an event .. 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 `_