`.
Define the cantilever beam model
--------------------------------
.. 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)
The cantilever beam example can be accessed in the usecases module :
.. code-block:: default
from openturns.usecases import cantilever_beam as cantilever_beam
cb = cantilever_beam.CantileverBeam()
The joint probability distribution of the input parameters is stored in the object `cb` :
.. code-block:: default
distribution = cb.distribution
We create the model.
.. code-block:: default
model = cb.model
Define the event
----------------
We create the event whose probability we want to estimate.
.. code-block:: default
vect = ot.RandomVector(distribution)
G = ot.CompositeRandomVector(model, vect)
event = ot.ThresholdEvent(G, ot.Greater(), 0.30)
Run a FORM analysis
-------------------
Define a solver
.. code-block:: default
optimAlgo = ot.Cobyla()
optimAlgo.setMaximumEvaluationNumber(1000)
optimAlgo.setMaximumAbsoluteError(1.0e-10)
optimAlgo.setMaximumRelativeError(1.0e-10)
optimAlgo.setMaximumResidualError(1.0e-10)
optimAlgo.setMaximumConstraintError(1.0e-10)
Run FORM
.. code-block:: default
algo = ot.FORM(optimAlgo, event, distribution.getMean())
algo.run()
result = algo.getResult()
Configure an importance sampling algorithm
------------------------------------------
The `getStandardSpaceDesignPoint` method returns the design point in the U-space.
.. code-block:: default
standardSpaceDesignPoint = result.getStandardSpaceDesignPoint()
standardSpaceDesignPoint
.. raw:: html
[-0.665643,4.31264,1.23029,-1.3689]
The key point is to define the importance distribution in the U-space. To define it, we use a multivariate standard Gaussian centered around the design point in the U-space.
.. code-block:: default
dimension = distribution.getDimension()
dimension
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
4
.. code-block:: default
myImportance = ot.Normal(dimension)
myImportance.setMean(standardSpaceDesignPoint)
myImportance
.. raw:: html
Normal(mu = [-0.665643,4.31264,1.23029,-1.3689], sigma = [1,1,1,1], R = [[ 1 0 0 0 ]
[ 0 1 0 0 ]
[ 0 0 1 0 ]
[ 0 0 0 1 ]])
Create the design of experiment corresponding to importance sampling. This generates a `WeightedExperiment` with weights fitting to the importance distribution.
.. code-block:: default
experiment = ot.ImportanceSamplingExperiment(myImportance)
type(experiment)
Create the standard event corresponding to the event. This pushes the original problem to the U-space, with Gaussian independent marginals.
.. code-block:: default
standardEvent = ot.StandardEvent(event)
Run the importance sampling simulation
--------------------------------------
We then create the simulation algorithm.
.. code-block:: default
algo = ot.ProbabilitySimulationAlgorithm(standardEvent, experiment)
algo.setMaximumCoefficientOfVariation(0.1)
algo.setMaximumOuterSampling(40000)
algo.run()
retrieve results
.. code-block:: default
result = algo.getResult()
probability = result.getProbabilityEstimate()
probability
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
4.3321474325557144e-07
In order to compute the confidence interval, we use the `getConfidenceLength` method, which returns the length of the interval. In order to compute the bounds of the interval, we divide this length by 2.
.. code-block:: default
alpha = 0.05
.. code-block:: default
pflen = result.getConfidenceLength(1-alpha)
print("%.2f%% confidence interval = [%f,%f]" % ((1-alpha)*100,probability-pflen/2,probability+pflen/2))
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
95.00% confidence interval = [0.000000,0.000001]
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.020 seconds)
.. _sphx_glr_download_auto_reliability_sensitivity_reliability_plot_estimate_probability_importance_sampling.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_estimate_probability_importance_sampling.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_estimate_probability_importance_sampling.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_