aDesign.getResult().getDesignOfExperiment().getOutputSample(), 1e-16) # Taylor Expansions ## taylorExpansionsMoments = persalys.TaylorExpansionMomentsAnalysis( 'myTaylorExpansionMoments', model) myStudy.add(taylorExpansionsMoments) taylorExpansionsMoments.run() taylorExpansionsMomentsResult = taylorExpansionsMoments.getResult() # Comparaison openturns.testing.assert_almost_equal( 0.059730458221, taylorExpansionsMomentsResult.getMeanFirstOrder()[0], 1e-13) # Monte Carlo ## montecarlo = persalys.MonteCarloAnalysis('myMonteCarlo', model) montecarlo.setMaximumCalls(1000) montecarlo.setMaximumCoefficientOfVariation(-1) myStudy.add(montecarlo) montecarlo.run() montecarloResult = montecarlo.getResult() # Comparaison openturns.testing.assert_almost_equal(0.0597109963361, montecarloResult.getMean()[3][0], 1e-13) openturns.testing.assert_almost_equal( 0.0114128746587, montecarloResult.getStandardDeviation()[3][0], 1e-13) meanCI = montecarloResult.getMeanConfidenceInterval() openturns.testing.assert_almost_equal(0.0590036320343,
# Model X0 = persalys.Input('X0', ot.Normal(1, 1)) X1 = persalys.Input('X1', ot.Normal(1, 1)) Y00 = persalys.Output('fake_Y0') Y00.setIsSelected(False) Y0 = persalys.Output('Y0') formula_Y00 = 'X0' formula_Y0 = 'sin(X0) + 8*X1' model = persalys.SymbolicPhysicalModel('aModelPhys', [X0, X1], [Y00, Y0], [formula_Y00, formula_Y0]) myStudy.add(model) # Monte Carlo ## analysis = persalys.MonteCarloAnalysis('myMonteCarlo', model) analysis.setLevelConfidenceInterval(0.93) analysis.setMaximumCalls(1000) analysis.setMaximumCoefficientOfVariation(-1) analysis.setMaximumElapsedTime(30) analysis.setSeed(2) myStudy.add(analysis) print(analysis) analysis.run() result = analysis.getResult() print("result=", result) print("PDF=", result.getPDF()) print("CDF=", result.getCDF()) print("outliers=", result.getOutliers())
kriging.setInterestVariables(['y0', 'y1']) myStudy.add(kriging) # 1-b Chaos ## chaos1 = persalys.FunctionalChaosAnalysis('chaos_1', probaDesign) chaos1.setChaosDegree(7) chaos1.setSparseChaos(True) chaos1.setTestSampleValidation(True) chaos1.setKFoldValidation(True) chaos1.setInterestVariables(['y1']) myStudy.add(chaos1) # 2- central tendancy ## # 2-a Monte Carlo ## monteCarlo = persalys.MonteCarloAnalysis('MonteCarlo', model1) monteCarlo.setIsConfidenceIntervalRequired(False) monteCarlo.setMaximumCoefficientOfVariation(-1.) monteCarlo.setMaximumElapsedTime(1000) monteCarlo.setMaximumCalls(20) monteCarlo.setSeed(2) monteCarlo.setInterestVariables(['y0', 'y1']) myStudy.add(monteCarlo) # 2-b Taylor Expansion ## taylor = persalys.TaylorExpansionMomentsAnalysis('Taylor', model1) taylor.setInterestVariables(['y0', 'y1']) myStudy.add(taylor) # 2-c Taylor Expansion which generate an error taylor2 = persalys.TaylorExpansionMomentsAnalysis('Taylor2', model1)