rootStrategy = ot.MediumSafe(solver) # %% # Direction sampling algorithm. # %% samplingStrategy = ot.OrthogonalDirection() # %% # Create a simulation algorithm. # %% algo = ot.DirectionalSampling(event, rootStrategy, samplingStrategy) algo.setMaximumCoefficientOfVariation(0.1) algo.setMaximumOuterSampling(40000) algo.setConvergenceStrategy(ot.Full()) algo.run() # %% # Retrieve results. # %% result = algo.getResult() probability = result.getProbabilityEstimate() print('Pf=', probability) # %% # We can observe the convergence history with the `drawProbabilityConvergence` # method. graph = algo.drawProbabilityConvergence() graph.setLogScale(ot.GraphImplementation.LOGX)
assert result.getVarianceEstimate() == 0.0, "wrong var" # case with last step threshold close from global threshold (before) print('-' * 100) event = ot.ThresholdEvent(Y, ot.Less(), -3.33832) mc = ot.ProbabilitySimulationAlgorithm(event) mc.run() print('MC: ', mc.getResult()) ot.RandomGenerator.SetSeed(65132) subset = ot.SubsetSampling(event) subset.setMaximumOuterSampling(500) subset.run() print('SUBSET:', subset.getResult()) print('steps=', subset.getStepsNumber()) print('T=', subset.getThresholdPerStep()) # case with last step threshold close from global threshold (after) print('-' * 100) event = ot.ThresholdEvent(Y, ot.Less(), -3.338325) mc = ot.ProbabilitySimulationAlgorithm(event) mc.run() print('MC: ', mc.getResult()) ot.RandomGenerator.SetSeed(65132) subset = ot.SubsetSampling(event) subset.setConvergenceStrategy(ot.Full()) subset.setMaximumOuterSampling(500) subset.run() print('SUBSET:', subset.getResult()) print('steps=', subset.getStepsNumber()) print('T=', subset.getThresholdPerStep())