1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#!/usr/bin/env python
import openturns as ot
ot.TESTPREAMBLE()
# create a function
dim = 4
function = ot.SymbolicFunction(["E", "F", "L", "I"], ["F*L^3/(3.*E*I)"])
# create a distribution
distribution = ot.Normal([50.0, 1.0, 10.0, 5.0], [1.0] * dim, ot.IdentityMatrix(dim))
vect = ot.RandomVector(distribution)
composite = ot.CompositeRandomVector(function, vect)
event = ot.ThresholdEvent(composite, ot.Less(), -3.0)
# create an ADS algorithm
n = int(1e4)
algo = ot.AdaptiveDirectionalStratification(event)
algo.setMaximumOuterSampling(n)
algo.setGamma([0.6, 0.4])
algo.run()
result = algo.getResult()
print(result)
# ADS-2+
algo2 = algo
algo2.setPartialStratification(True)
algo2.run()
print("T=", algo2.getTStatistic())
result = algo2.getResult()
print(result)
# DPADS-2
algo3 = algo2
algo3.setQuadrantOrientation([1.0] * dim) # enables DPADS-2, sets design
algo3.run()
result = algo3.getResult()
print(result)
|