copulas/multivariate/tree.py
def _build_first_tree(self):
        """Build the first tree with n-1 variable."""
        # Prim's algorithm
        neg_tau = -1.0 * abs(self.tau_matrix)
        X = {0}

        while len(X) != self.n_nodes:
            adj_set = set()
            for x in X:
                for k in range(self.n_nodes):
                    if k not in X and k != x:
                        adj_set.add((x, k))

            # find edge with maximum
            edge = sorted(adj_set, key=lambda e: neg_tau[e[0]][e[1]])[0]
            name, theta = Bivariate.select_copula(self.u_matrix[:, (edge[0], edge[1])])

            left, right = sorted([edge[0], edge[1]])
            new_edge = Edge(len(X) - 1, left, right, name, theta)
            new_edge.tau = self.tau_matrix[edge[0], edge[1]]
            self.edges.append(new_edge)
            X.add(edge[1])
Build the first tree with n-1 variable.
Build the first tree with n-1 variable.
Build the first tree with n - 1 variable .
def _build_first_tree(self):
        neg_tau = -1.0 * abs(self.tau_matrix)
        X = {0}
        while len(X) != self.n_nodes:
            adj_set = set()
            for x in X:
                for k in range(self.n_nodes):
                    if k not in X and k != x:
                        adj_set.add((x, k))
            edge = sorted(adj_set, key=lambda e: neg_tau[e[0]][e[1]])[0]
            name, theta = Bivariate.select_copula(self.u_matrix[:, (edge[0], edge[1])])
            left, right = sorted([edge[0], edge[1]])
            new_edge = Edge(len(X) - 1, left, right, name, theta)
            new_edge.tau = self.tau_matrix[edge[0], edge[1]]
            self.edges.append(new_edge)
            X.add(edge[1])
def _build_first_tree ( self ) : neg_tau = - 1.0 * abs ( self . tau_matrix ) X = { 0 } while len ( X ) != self . n_nodes : adj_set = set ( ) for x in X : for k in range ( self . n_nodes ) : if k not in X and k != x : adj_set . add ( ( x , k ) ) edge = sorted ( adj_set , key = lambda e : neg_tau [ e [ 0 ] ] [ e [ 1 ] ] ) [ 0 ] name , theta = Bivariate . select_copula ( self . u_matrix [ : , ( edge [ 0 ] , edge [ 1 ] ) ] ) left , right = sorted ( [ edge [ 0 ] , edge [ 1 ] ] ) new_edge = Edge ( len ( X ) - 1 , left , right , name , theta ) new_edge . tau = self . tau_matrix [ edge [ 0 ] , edge [ 1 ] ] self . edges . append ( new_edge ) X . add ( edge [ 1 ] )
Build the first tree with n-1 variable.
Build the first tree with n - 1 variable .
"""Build the first tree with n-1 variable.""" # Prim's algorithm # find edge with maximum
self