Estimate failure probability sensitivity with simulation

In this example we estimate the sensitivity of a failure probability with respect to the parameters of the input distribution using the SimulationSensitivityAnalysis class.

For a failure event \mathcal{F} = \{g(\vect{X}) > s\} with input density f_{\theta}(\cdot), the sensitivity with respect to \theta is:

\frac{\partial P_f}{\partial \theta}
= \mathbb{E}\left[\mathbf{1}_{\mathcal{F}}(\vect{X})
\frac{\partial \log f_{\theta}(\vect{X})}{\partial \theta}\right].

With Monte Carlo sampling this expectation is estimated by the empirical mean over the input sample. With importance sampling with importance density h, each realization is weighted by the likelihood ratio w = f_{\theta}/h:

\frac{\partial P_f}{\partial \theta}
\approx \frac{1}{n}\sum_{i=1}^n
\mathbf{1}_{\mathcal{F}}(\vect{X}_i)
\frac{\partial \log f_{\theta}(\vect{X}_i)}{\partial \theta} w_i.

We first run a Monte Carlo reference, then importance sampling in the physical space, and finally importance sampling in the standard space mapped back to the physical space.

import openturns as ot
import openturns.viewer as otv

ot.RandomGenerator.SetSeed(0)

Define the model

A linear limit-state with Gaussian inputs.

distribution = ot.Normal([0.0] * 2, [1.0] * 2)
model = ot.SymbolicFunction(["x0", "x1"], ["x0 + 2.0 * x1"])
threshold = 3.0

Monte Carlo reference

With uniform weights the samples stored by the memoized model are enough.

Importance Factors from Simulation - v0
Monte Carlo Pf = 0.08888888888888888
Monte Carlo sensitivity = [mu_0 : 0.0646111, sigma_0 : 0.0303473, mu_1 : 0.145922, sigma_1 : 0.181368]
Monte Carlo mean point = [0.726875,1.64162]

Importance sampling in the physical space

The importance distribution is centered on the failure domain. The likelihood ratio must be passed as weights, otherwise the sensitivity is biased.

Importance sampling Pf = 0.09553770376063518
Importance sampling sensitivity = [mu_0 : 0.0789529, sigma_0 : 0.0414191, mu_1 : 0.150642, sigma_1 : 0.170741]
Importance sampling mean point = [0.826406,1.57678]

Importance sampling in the standard space

In practice importance sampling is often performed in the standard space through a StandardEvent. The sensitivity with respect to the physical distribution is then recovered by mapping the standard input sample back to the physical space and weighting by the ratio of the standard density over the importance density.

Standard-space Pf = 0.0870263073049596
Standard-space sensitivity w.r.t. physical parameters = [mu_0 : 0.0646741, sigma_0 : 0.0404083, mu_1 : 0.145542, sigma_1 : 0.186382]