def _set_points_and_weights(self): """ Private function that sets the quadrature points. :param Poly self: An instance of the Poly object. """ self.quadrature = Quadrature(parameters=self.parameters, basis=self.basis, \ points=self.inputs, mesh=self.mesh) quadrature_points, quadrature_weights = self.quadrature.get_points_and_weights( ) if self.subsampling_algorithm_name is not None: P = self.get_poly(quadrature_points) W = np.mat(np.diag(np.sqrt(quadrature_weights))) A = W * P.T self.A = A mm, nn = A.shape m_refined = int(np.round(self.sampling_ratio * nn)) z = self.subsampling_algorithm_function(A, m_refined) self._quadrature_points = quadrature_points[z, :] self._quadrature_weights = quadrature_weights[z] / np.sum( quadrature_weights[z]) else: self._quadrature_points = quadrature_points self._quadrature_weights = quadrature_weights P = self.get_poly(quadrature_points) W = np.mat(np.diag(np.sqrt(quadrature_weights))) A = W * P.T self.A = A
def _set_statistics(self): """ Private method that is used within the statistics routines. """ if self.statistics_object is None: if hasattr(self, 'inv_R_Psi'): # quad_pts, quad_wts = self.quadrature.get_points_and_weights() N_quad = 20000 quad_pts = self.corr.get_correlated_samples(N=N_quad) quad_wts = 1.0 / N_quad * np.ones(N_quad) poly_vandermonde_matrix = self.get_poly(quad_pts) elif self.method != 'numerical-integration' and self.dimensions <= 6 and self.highest_order <= MAXIMUM_ORDER_FOR_STATS: quad = Quadrature(parameters=self.parameters, basis=Basis('tensor-grid', orders= np.array(self.parameters_order) + 1), \ mesh='tensor-grid', points=None) quad_pts, quad_wts = quad.get_points_and_weights() poly_vandermonde_matrix = self.get_poly(quad_pts) elif self.mesh == 'monte-carlo': quad = Quadrature(parameters=self.parameters, basis=self.basis, mesh=self.mesh, points=None, oversampling=10.0) quad_pts, quad_wts = quad.get_points_and_weights() N_quad = len(quad_wts) quad_wts = 1.0 / N_quad * np.ones(N_quad) poly_vandermonde_matrix = self.get_poly(quad_pts) else: poly_vandermonde_matrix = self.get_poly( self._quadrature_points) quad_pts, quad_wts = self.get_points_and_weights() if self.highest_order <= MAXIMUM_ORDER_FOR_STATS and ( self.basis.basis_type.lower() == 'total-order' or self.basis.basis_type.lower() == 'hyperbolic-basis'): self.statistics_object = Statistics(self.parameters, self.basis, self.coefficients, quad_pts, \ quad_wts, poly_vandermonde_matrix, max_sobol_order=self.highest_order) else: self.statistics_object = Statistics(self.parameters, self.basis, self.coefficients, quad_pts, \ quad_wts, poly_vandermonde_matrix, max_sobol_order=MAXIMUM_ORDER_FOR_STATS)
def _set_statistics(self): """ Private method that is used withn the statistics routines. """ if self.statistics_object is None: if self.method != 'numerical-integration' and self.dimensions <= 6 and self.highest_order <= MAXIMUM_ORDER_FOR_STATS: quad = Quadrature(parameters=self.parameters, basis=Basis('tensor-grid', orders= np.array(self.parameters_order) + 1), \ mesh='tensor-grid', points=None) quad_pts, quad_wts = quad.get_points_and_weights() poly_vandermonde_matrix = self.get_poly(quad_pts) else: poly_vandermonde_matrix = self.get_poly(self._quadrature_points) quad_pts, quad_wts = self.get_points_and_weights() if self.highest_order <= MAXIMUM_ORDER_FOR_STATS: self.statistics_object = Statistics(self.parameters, self.basis, self.coefficients, quad_pts, \ quad_wts, poly_vandermonde_matrix, max_sobol_order=self.highest_order) else: self.statistics_object = Statistics(self.parameters, self.basis, self.coefficients, quad_pts, \ quad_wts, poly_vandermonde_matrix, max_sobol_order=MAXIMUM_ORDER_FOR_STATS)