.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_example/plot_example1.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_example_plot_example1.py: Example 1: Use of AK- MCS on Four Branch function ------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 7-16 .. code-block:: default import openturns as ot from openturns.viewer import View import numpy as np import otak ot.RandomGenerator.SetSeed(1) .. GENERATED FROM PYTHON SOURCE LINES 17-18 | Definition of Input distribution .. GENERATED FROM PYTHON SOURCE LINES 18-23 .. code-block:: default dim_inputs = 2 dist_x = ot.Normal([0.0, 0.0], [1., 1.], ot.CorrelationMatrix(dim_inputs)) inputVector = ot.RandomVector(dist_x) .. GENERATED FROM PYTHON SOURCE LINES 24-25 | Definition of limit state function .. GENERATED FROM PYTHON SOURCE LINES 25-41 .. code-block:: default def four_branch(x): x1 = x[0] x2 = x[1] k = x[2] g1 = 3+0.1*(x1-x2)**2-(x1+x2)/np.sqrt(2) g2 = 3+0.1*(x1-x2)**2+(x1+x2)/np.sqrt(2) g3 = (x1-x2)+k/np.sqrt(2) g4 =(x2-x1)+k/np.sqrt(2) return [min((g1,g2,g3,g4))] my_four_branch = ot.PythonFunction(3, 1, four_branch) index_frozen = [2] my_four_branch_6 = ot.ParametricFunction(my_four_branch, index_frozen, [6]) .. GENERATED FROM PYTHON SOURCE LINES 42-43 | Definition of event .. GENERATED FROM PYTHON SOURCE LINES 43-47 .. code-block:: default Y = ot.CompositeRandomVector(my_four_branch_6, inputVector) my_event4b = ot.ThresholdEvent(Y,ot.Less(),0.0) .. GENERATED FROM PYTHON SOURCE LINES 48-49 | Run of AK MCS .. GENERATED FROM PYTHON SOURCE LINES 49-73 .. code-block:: default dim_4b = 2 basis = ot.ConstantBasisFactory(dim_4b).build() covarianceModel = ot.MaternModel(dim_4b) n_MC_4b = 10000 n_DoE_4b = 20 sim_budget_4b = 200 verbose = False criterion = 2 my_AK_four_branch = otak.AK_MCSAlgorithm(my_event4b, n_MC_4b, n_DoE_4b, sim_budget_4b, basis, covarianceModel, criterion, verbose) my_AK_four_branch.compute_proba() print('Probability of failure',my_AK_four_branch.getFailureProbability()) print('Simulation budget',my_AK_four_branch.getSimBudget()) print('Coefficient of variation',my_AK_four_branch.getCoefficientOfVariation()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Probability of failure 0.0044 Simulation budget 61 Coefficient of variation 0.1504236441762821 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 7.062 seconds) .. _sphx_glr_download_auto_example_plot_example1.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_example1.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_example1.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_