Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why are there a LOT of repeated calculations in Tree.get_tau_matrix()? possibly bug? #316

Open
faniuy opened this issue Mar 1, 2022 · 0 comments
Labels
question General question about the software under discussion Issue is currently being discussed

Comments

@faniuy
Copy link

faniuy commented Mar 1, 2022

Below is the code from copulas/multivariate/tree.py
The inner loop(j loop) repeatedly calculates kendalltau for the same data, and the columns of tau matrix are all the same.

def get_tau_matrix(self):
        num_edges = len(self.edges)
        tau = np.empty([num_edges, num_edges])
        for i in range(num_edges):
            edge = self.edges[i]
            for j in edge.neighbors:  
                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 and right_u are the same for different j's.
                tau[i, j], pvalue = scipy.stats.kendalltau(left_u, right_u) 

        return tau
@faniuy faniuy added under discussion Issue is currently being discussed question General question about the software labels Mar 1, 2022
@faniuy faniuy changed the title Why is there a LOT of repeated calculations in Tree.get_tau_matrix()? possibly bug? Why are there a LOT of repeated calculations in Tree.get_tau_matrix()? possibly bug? Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question General question about the software under discussion Issue is currently being discussed
Projects
None yet
Development

No branches or pull requests

1 participant