def setPolynomialChaosResult(self, chaosResult): """ Accessor to the polynomial chaos result. Parameters ---------- chaosResult : :py:class:`openturns.FunctionalChaosResult` The polynomial chaos result. """ try: ot.FunctionalChaosResult(chaosResult) except NotImplementedError: raise Exception('The given parameter is not an FunctionalChaosResult.') self._chaosResult = chaosResult self._userChaos = True
for i in range(len(x_quadq)): print("Quad10 (49) y_quad1 study#" + str(i)) x_c, y, q = fl(x_quadq[i]) y_quadq.append(y) pc_predictor_r.fit(x_trainr, y_trainr) pc_predictor_q.fit(x_quadq, y_quadq) pc_predictor_ls1.fit(x_train5, y_train5) pc_predictor_ls2.fit(x_train3, y_train3) surror = pc_predictor_r.predictor.pc_result surroq = pc_predictor_q.predictor.pc_result surrols1 = pc_predictor_ls1.predictor.pc_result surrols2 = pc_predictor_ls2.predictor.pc_result Surror = ot.FunctionalChaosResult(surror) Coeffsr = Surror.getCoefficients() Surroq = ot.FunctionalChaosResult(surroq) Coeffsq = Surroq.getCoefficients() Surrols1 = ot.FunctionalChaosResult(surrols1) Coeffls1 = Surrols1.getCoefficients() Surrols2 = ot.FunctionalChaosResult(surrols2) Coeffls2 = Surrols2.getCoefficients() g_ref = np.array(Coeffsr) (n_pc, k) = np.shape(g_ref) gq = np.array(Coeffsq) gls1 = np.array(Coeffls1) gls2 = np.array(Coeffls2) LC_pc_q = np.zeros(n_pc) LC_pc_ls1 = np.zeros(n_pc)
distribution_corr = ot.ComposedDistribution([ot.Normal()] * 2, copula) # %% # ANCOVA needs a functional decomposition of the model enumerateFunction = ot.LinearEnumerateFunction(2) productBasis = ot.OrthogonalProductPolynomialFactory([ot.HermiteFactory()] * 2, enumerateFunction) adaptiveStrategy = ot.FixedStrategy( productBasis, enumerateFunction.getStrataCumulatedCardinal(4)) samplingSize = 250 projectionStrategy = ot.LeastSquaresStrategy( ot.MonteCarloExperiment(samplingSize)) algo = ot.FunctionalChaosAlgorithm(model, distribution, adaptiveStrategy, projectionStrategy) algo.run() result = ot.FunctionalChaosResult(algo.getResult()) # %% # Create the input sample taking account the correlation size = 2000 sample = distribution_corr.getSample(size) # %% # Perform the decomposition ancova = ot.ANCOVA(result, sample) # Compute the ANCOVA indices (first order and uncorrelated indices are computed together) indices = ancova.getIndices() # Retrieve uncorrelated indices uncorrelatedIndices = ancova.getUncorrelatedIndices() # Retrieve correlated indices: correlatedIndices = indices - uncorrelatedIndices