Estimate a probability with Monte CarloΒΆ

In this example we estimate a probability by means of a simulation algorithm, the Monte-Carlo algorithm. To do this, we need the classes MonteCarloExperiment and ProbabilitySimulationAlgorithm. We consider the axial stressed beam example.

from openturns.usecases import stressed_beam
import openturns as ot

We load the model from the usecases module :

We get the joint distribution of the parameters.

The model is also stored in the data class :

We create the event whose probability we want to estimate.

Create a Monte Carlo algorithm.

Retrieve results.

result = algo.getResult()
probability = result.getProbabilityEstimate()
print("Pf=", probability)
Pf= 0.03029829767296579

Print the size of used sample and compare it with the budget size (1e5)

print(f"Sample used to get the probability = {len(algo.getOutputSample())}")
Sample used to get the probability = 12806