Ejemplo n.º 1
0
sobol.setReplicationSize(3)
sobol.setBlockSize(1)
sobol.setSeed(2)
sobol.setInterestVariables(['y0', 'y1'])
myStudy.add(sobol)

# 4-b SRC ##
src = persalys.SRCAnalysis('SRC', model1)
src.setSimulationsNumber(20)
src.setSeed(2)
src.setInterestVariables(['y0', 'y1'])
myStudy.add(src)

# 7- data analysis ##
dataAnalysis = persalys.DataAnalysis('DataAnalysis', model3)
myStudy.add(dataAnalysis)

# 8- Marginals inference ##
inference = persalys.InferenceAnalysis('inference', model3)
inference.setInterestVariables(['x_0', 'x_3'])
factories = [ot.NormalFactory(), ot.GumbelFactory()]
inference.setDistributionsFactories('x_3', factories)
inference.setLevel(0.1)
myStudy.add(inference)

# 9- Copula inference ##
copulaInference = persalys.CopulaInferenceAnalysis('copulaInference', model3)
factories = [ot.NormalCopulaFactory(), ot.GumbelCopulaFactory()]
copulaInference.setDistributionsFactories(['x_0', 'x_3'], factories)
myStudy.add(copulaInference)
# Model
filename = 'data2.csv'
ot.RandomGenerator.SetSeed(0)
sample = ot.Normal(3).getSample(300)
sample.stack(ot.Gumbel().getSample(300))
sample.setDescription(['X0', 'X1', 'X2', 'X3'])
sample.exportToCSVFile(filename, ',')
columns = [0, 2, 3]

model = persalys.DataModel('myDataModel', "data2.csv", columns)
myStudy.add(model)
print(model)

# Dependencies inference analysis ##
analysis = persalys.CopulaInferenceAnalysis('analysis', model)
variables = ["X0", "X3"]
factories = [ot.NormalCopulaFactory(), ot.GumbelCopulaFactory()]
analysis.setDistributionsFactories(variables, factories)
myStudy.add(analysis)
print(analysis)

analysis.run()

result = analysis.getResult()
print("result=", result)
print(result.getCopulaInferenceSetResult(variables))

# script
script = myStudy.getPythonScript()
print(script)