def setUp(self): """ Set up the problem for :meth:`bet.calculateP.voronoiHistogram.center_and_layer1_points` """ self.r_ratio = self.r_size/self.sur_domain[:,1] super(center_and_layer1_points_binsize, self).create_output() output = vHist.center_and_layer1_points_binsize(self.center_pts_per_edge, self.center, self.r_size, self.sur_domain) self.points, self.interior_and_layer1_VH, self.rect_domain_VH = output
def setUp(self): """ Set up the problem for :meth:`bet.calculateP.voronoiHistogram.center_and_layer1_points` """ self.r_ratio = self.r_size / self.sur_domain[:, 1] super(center_and_layer1_points_binsize, self).create_output() output = vHist.center_and_layer1_points_binsize( self.center_pts_per_edge, self.center, self.r_size, self.sur_domain) self.points, self.interior_and_layer1_VH, self.rect_domain_VH = output
def uniform_hyperrectangle_binsize(data, Q_ref, bin_size, center_pts_per_edge=1): r""" Creates a simple function approximation of :math:`\rho_{\mathcal{D},M}` where :math:`\rho_{\mathcal{D},M}` is a uniform probability density centered at Q_ref with bin_size of the width of D. Since rho_D is a uniform distribution on a hyperrectanlge we should be able to represent it exactly with ``M = 3^mdim`` or rather ``len(d_distr_samples) == 3^mdim``. :param bin_size: The size used to determine the width of the uniform distribution :type bin_size: double or list() :param int num_d_emulate: Number of samples used to emulate using an MC assumption :param data: Array containing QoI data where the QoI is mdim diminsional :type data: :class:`~numpy.ndarray` of size (num_samples, mdim) :param Q_ref: :math:`Q(\lambda_{reference})` :type Q_ref: :class:`~numpy.ndarray` of size (mdim,) :param list() center_pts_per_edge: number of center points per edge and additional two points will be added to create the bounding layer :rtype: tuple :returns: (rho_D_M, d_distr_samples, d_Tree) where ``rho_D_M`` is (M,) and ``d_distr_samples`` are (M, mdim) :class:`~numpy.ndarray` and `d_Tree` is the :class:`~scipy.spatial.KDTree` for d_distr_samples """ data = util.fix_dimensions_data(data) if not isinstance(center_pts_per_edge, collections.Iterable): center_pts_per_edge = np.ones((data.shape[1],)) * center_pts_per_edge else: if not len(center_pts_per_edge) == data.shape[1]: center_pts_per_edge = np.ones((data.shape[1],)) print 'Warning: center_pts_per_edge dimension mismatch.' print 'Using 1 in each dimension.' if np.any(np.less(center_pts_per_edge, 0)): print 'Warning: center_pts_per_edge must be greater than 0' if not isinstance(bin_size, collections.Iterable): bin_size = bin_size*np.ones((data.shape[1],)) if np.any(np.less(bin_size, 0)): print 'Warning: center_pts_per_edge must be greater than 0' sur_domain = np.array([np.min(data, 0), np.max(data, 0)]).transpose() points, _, rect_domain = vHist.center_and_layer1_points_binsize(center_pts_per_edge, Q_ref, bin_size, sur_domain) edges = vHist.edges_regular(center_pts_per_edge, rect_domain, sur_domain) _, volumes, _ = vHist.histogramdd_volumes(edges, points) return vHist.simple_fun_uniform(points, volumes, rect_domain)
def uniform_hyperrectangle_binsize(data, Q_ref, bin_size, center_pts_per_edge=1): r""" Creates a simple function approximation of :math:`\rho_{\mathcal{D},M}` where :math:`\rho_{\mathcal{D},M}` is a uniform probability density centered at Q_ref with bin_size of the width of D. Since rho_D is a uniform distribution on a hyperrectanlge we should be able to represent it exactly with ``M = 3^mdim`` or rather ``len(d_distr_samples) == 3^mdim``. :param bin_size: The size used to determine the width of the uniform distribution :type bin_size: double or list() :param int num_d_emulate: Number of samples used to emulate using an MC assumption :param data: Array containing QoI data where the QoI is mdim diminsional :type data: :class:`~numpy.ndarray` of size (num_samples, mdim) :param Q_ref: :math:`Q(\lambda_{reference})` :type Q_ref: :class:`~numpy.ndarray` of size (mdim,) :param list() center_pts_per_edge: number of center points per edge and additional two points will be added to create the bounding layer :rtype: tuple :returns: (rho_D_M, d_distr_samples, d_Tree) where ``rho_D_M`` and ``d_distr_samples`` are (mdim, M) :class:`~numpy.ndarray` and `d_Tree` is the :class:`~scipy.spatial.KDTree` for d_distr_samples """ if len(data.shape) == 1: data = np.expand_dims(data, axis=1) data_max = np.max(data, 0) data_min = np.min(data, 0) sur_domain = np.zeros((data.shape[1], 2)) sur_domain[:, 0] = data_min sur_domain[:, 1] = data_max points, _, rect_domain = vHist.center_and_layer1_points_binsize(center_pts_per_edge, Q_ref, bin_size, sur_domain) edges = vHist.edges_regular_binsize(center_pts_per_edge, Q_ref, bin_size, sur_domain) _, volumes, _ = vHist.histogramdd_volumes(edges, points) return vHist.simple_fun_uniform(points, volumes, rect_domain)