copulas/multivariate/tree.py
def prepare_next_tree(self):
        """Prepare conditional U matrix for next tree."""
        for edge in self.edges:
            copula_theta = edge.theta

            if self.level == 1:
                left_u = self.u_matrix[:, edge.L]
                right_u = self.u_matrix[:, edge.R]

            else:
                left_parent, right_parent = edge.parents
                left_u, right_u = Edge.get_conditional_uni(left_parent, right_parent)

            # compute conditional cdfs C(i|j) = dC(i,j)/duj and dC(i,j)/du
            left_u = [x for x in left_u if x is not None]
            right_u = [x for x in right_u if x is not None]
            X_left_right = np.array([[x, y] for x, y in zip(left_u, right_u)])
            X_right_left = np.array([[x, y] for x, y in zip(right_u, left_u)])

            copula = Bivariate(edge.name)
            copula.theta = copula_theta
            left_given_right = copula.partial_derivative(X_left_right)
            right_given_left = copula.partial_derivative(X_right_left)

            # correction of 0 or 1
            left_given_right[left_given_right == 0] = EPSILON
            right_given_left[right_given_left == 0] = EPSILON
            left_given_right[left_given_right == 1] = 1 - EPSILON
            right_given_left[right_given_left == 1] = 1 - EPSILON
            edge.U = np.array([left_given_right, right_given_left])
Prepare conditional U matrix for next tree.
Prepare conditional U matrix for next tree.
Prepare conditional U matrix for next tree .
def prepare_next_tree(self):
        for edge in self.edges:
            copula_theta = edge.theta
            if self.level == 1:
                left_u = self.u_matrix[:, edge.L]
                right_u = self.u_matrix[:, edge.R]
            else:
                left_parent, right_parent = edge.parents
                left_u, right_u = Edge.get_conditional_uni(left_parent, right_parent)
            left_u = [x for x in left_u if x is not None]
            right_u = [x for x in right_u if x is not None]
            X_left_right = np.array([[x, y] for x, y in zip(left_u, right_u)])
            X_right_left = np.array([[x, y] for x, y in zip(right_u, left_u)])
            copula = Bivariate(edge.name)
            copula.theta = copula_theta
            left_given_right = copula.partial_derivative(X_left_right)
            right_given_left = copula.partial_derivative(X_right_left)
            left_given_right[left_given_right == 0] = EPSILON
            right_given_left[right_given_left == 0] = EPSILON
            left_given_right[left_given_right == 1] = 1 - EPSILON
            right_given_left[right_given_left == 1] = 1 - EPSILON
            edge.U = np.array([left_given_right, right_given_left])
def prepare_next_tree ( self ) : for edge in self . edges : copula_theta = edge . theta if self . level == 1 : left_u = self . u_matrix [ : , edge . L ] right_u = self . u_matrix [ : , edge . R ] else : left_parent , right_parent = edge . parents left_u , right_u = Edge . get_conditional_uni ( left_parent , right_parent ) left_u = [ x for x in left_u if x is not None ] right_u = [ x for x in right_u if x is not None ] X_left_right = np . array ( [ [ x , y ] for x , y in zip ( left_u , right_u ) ] ) X_right_left = np . array ( [ [ x , y ] for x , y in zip ( right_u , left_u ) ] ) copula = Bivariate ( edge . name ) copula . theta = copula_theta left_given_right = copula . partial_derivative ( X_left_right ) right_given_left = copula . partial_derivative ( X_right_left ) left_given_right [ left_given_right == 0 ] = EPSILON right_given_left [ right_given_left == 0 ] = EPSILON left_given_right [ left_given_right == 1 ] = 1 - EPSILON right_given_left [ right_given_left == 1 ] = 1 - EPSILON edge . U = np . array ( [ left_given_right , right_given_left ] )
Prepare conditional U matrix for next tree.
Prepare conditional U matrix for next tree .
"""Prepare conditional U matrix for next tree.""" # compute conditional cdfs C(i|j) = dC(i,j)/duj and dC(i,j)/du # correction of 0 or 1
self