13
# we create an analytical function
14
input = Description(dimension);
20
foutput = Description(1);
22
print "output=", foutput
24
formulas = Description(foutput.getSize());
25
formulas[0] = "sin(x0)+7*sin(x1)^2+0.1*x2^4*sin(x0)";
27
analytical = NumericalMathFunction(input, foutput, formulas);
28
print "analytical=", analytical
30
# we create a collection of uniform distributions over [-Pi; Pi[
31
aCollection = DistributionCollection();
32
for i in range(dimension) :
33
aCollection.add(Distribution(Uniform(-pi, +pi)));
35
# we create an independent copula
36
aCopula = IndependentCopula(aCollection.getSize());
37
aCopula.setName("an independent copula");
39
# we create one distribution object
40
aDistribution = ComposedDistribution(aCollection, Copula(aCopula));
41
aDistribution.setName("a uniform distribution");
43
# we create two input samples for the function
44
firstInputSample = aDistribution.getNumericalSample(sampleSize);
45
secondInputSample = aDistribution.getNumericalSample(sampleSize);
47
# Choose which indices to compute
48
indiceParameters = CorrelationAnalysisSobolIndiceParameters();
49
# Choose to compute indices until order 3 (requires computation of inferior order indices)
50
indiceParameters.setMaximumOrder(3);
51
# Choose to compute total order indices
52
indiceParameters.setTotalIndiceComputation(True);
54
# Compute the Sobol' indices
55
myResult = CorrelationAnalysis.SobolIndice(indiceParameters, firstInputSample, secondInputSample, analytical);
57
# Retrieve the indices from result according to the selected indices via indiceParameters
58
# firstOrderIndice[i] is the first order indice of variable i
59
firstOrderIndice = NumericalPoint(myResult.getFirstOrderIndice());
60
# secondOrderIndice(i, j) is the second order indice for both variables i and j (i not equal to j)
61
secondOrderIndice = SymmetricMatrix(myResult.getSecondOrderIndice());
62
# thirdOrderIndice(i, j, k) is the indice for the subset of variables {i, j, k} (i, j and k are different)
63
thirdOrderIndice = SymmetricTensor(myResult.getThirdOrderIndice());
64
# totalOrder[i] is the total indice for variable i
65
totalOrderIndice = NumericalPoint(myResult.getTotalOrderIndice());
67
# stream out the indices
68
print "first order indices=", firstOrderIndice;
69
print "second order indices=", secondOrderIndice;
70
print "third order indices=", thirdOrderIndice;
71
print "total order indices=", totalOrderIndice;
13
# we create an analytical function
14
input = Description(dimension);
20
foutput = Description(1);
22
print "output=", foutput
24
formulas = Description(foutput.getSize());
25
formulas[0] = "sin(x0)+7*sin(x1)^2+0.1*x2^4*sin(x0)";
27
analytical = NumericalMathFunction(input, foutput, formulas);
28
print "analytical=", analytical
30
# we create a collection of uniform distributions over [-Pi; Pi[
31
aCollection = DistributionCollection();
32
for i in range(dimension) :
33
aCollection.add(Distribution(Uniform(-pi, +pi)));
35
# we create an independent copula
36
aCopula = IndependentCopula(aCollection.getSize());
37
aCopula.setName("an independent copula");
39
# we create one distribution object
40
aDistribution = ComposedDistribution(aCollection, Copula(aCopula));
41
aDistribution.setName("a uniform distribution");
43
# we create two input samples for the function
44
firstInputSample = aDistribution.getNumericalSample(sampleSize);
45
secondInputSample = aDistribution.getNumericalSample(sampleSize);
47
# Choose which indices to compute
48
indiceParameters = CorrelationAnalysisSobolIndiceParameters();
49
# Choose to compute indices until order 3 (requires computation of inferior order indices)
50
indiceParameters.setMaximumOrder(3);
51
# Choose to compute total order indices
52
indiceParameters.setTotalIndiceComputation(True);
54
# Compute the Sobol' indices
55
myResult = CorrelationAnalysis.SobolIndice(indiceParameters, firstInputSample, secondInputSample, analytical);
57
# Retrieve the indices from result according to the selected indices via indiceParameters
58
# firstOrderIndice[i] is the first order indice of variable i
59
firstOrderIndice = NumericalPoint(myResult.getFirstOrderIndice());
60
# secondOrderIndice(i, j) is the second order indice for both variables i and j (i not equal to j)
61
secondOrderIndice = SymmetricMatrix(myResult.getSecondOrderIndice());
62
# thirdOrderIndice(i, j, k) is the indice for the subset of variables {i, j, k} (i, j and k are different)
63
thirdOrderIndice = SymmetricTensor(myResult.getThirdOrderIndice());
64
# totalOrder[i] is the total indice for variable i
65
totalOrderIndice = NumericalPoint(myResult.getTotalOrderIndice());
67
# stream out the indices
68
print "first order indices=", repr(firstOrderIndice);
69
print "second order indices=", repr(secondOrderIndice);
70
print "third order indices=", repr(thirdOrderIndice);
71
print "total order indices=", repr(totalOrderIndice);