def _calc(self, x, y):
x = np.array(x)<EOL>y = np.array(y)<EOL>n = len(y)<EOL>perm = list(range(n))<EOL>perm.sort(key=lambda a: (x[a], y[a]))<EOL>vals = y[perm]<EOL>ExtraY = <NUM_LIT:0><EOL>ExtraX = <NUM_LIT:0><EOL>ACount = <NUM_LIT:0><EOL>BCount = <NUM_LIT:0><EOL>CCount = <NUM_LIT:0><EOL>DCount = <NUM_LIT:0><EOL>ECount = <NUM_LIT:0><EOL>DCount = <NUM_LIT:0><EOL>Concordant = <NUM_LIT:0><EOL>Discordant = <NUM_LIT:0><EOL>li = [None] * (n - <NUM_LIT:1>)<EOL>ri = [None] * (n - <NUM_LIT:1>)<EOL>ld = np.zeros(n)<EOL>nequal = np.zeros(n)<EOL>for i in range(<NUM_LIT:1>, n):<EOL><INDENT>NumBefore = <NUM_LIT:0><EOL>NumEqual = <NUM_LIT:1><EOL>root = <NUM_LIT:0><EOL>x0 = x[perm[i - <NUM_LIT:1>]]<EOL>y0 = y[perm[i - <NUM_LIT:1>]]<EOL>x1 = x[perm[i]]<EOL>y1 = y[perm[i]]<EOL>if x0 != x1:<EOL><INDENT>DCount = <NUM_LIT:0><EOL>ECount = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>if y0 == y1:<EOL><INDENT>ECount += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>DCount += ECount<EOL>ECount = <NUM_LIT:1><EOL><DEDENT><DEDENT>root = <NUM_LIT:0><EOL>inserting = True<EOL>while inserting:<EOL><INDENT>current = y[perm[i]]<EOL>if current > y[perm[root]]:<EOL><INDENT>NumBefore += <NUM_LIT:1> + ld[root] + nequal[root]<EOL>if ri[root] is None:<EOL><INDENT>ri[root] = i<EOL>inserting = False<EOL><DEDENT>else:<EOL><INDENT>root = ri[root]<EOL><DEDENT><DEDENT>elif current < y[perm[root]]:<EOL><INDENT>ld[root] += <NUM_LIT:1><EOL>if li[root] is None:<EOL><INDENT>li[root] = i<EOL>inserting = False<EOL><DEDENT>else:<EOL><INDENT>root = li[root]<EOL><DEDENT><DEDENT>elif current == y[perm[root]]:<EOL><INDENT>NumBefore += ld[root]<EOL>NumEqual += nequal[root] + <NUM_LIT:1><EOL>nequal[root] += <NUM_LIT:1><EOL>inserting = False<EOL><DEDENT><DEDENT>ACount = NumBefore - DCount<EOL>BCount = NumEqual - ECount<EOL>CCount = i - (ACount + BCount + DCount + ECount - <NUM_LIT:1>)<EOL>ExtraY += DCount<EOL>ExtraX += BCount<EOL>Concordant += ACount<EOL>Discordant += CCount<EOL><DEDENT>cd = Concordant + Discordant<EOL>num = Concordant - Discordant<EOL>tau = num / np.sqrt((cd + ExtraX) * (cd + ExtraY))<EOL>v = (<NUM_LIT> * n + <NUM_LIT:10>) / (<NUM_LIT> * n * (n - <NUM_LIT:1>))<EOL>z = tau / np.sqrt(v)<EOL>pval = erfc(np.abs(z) / <NUM_LIT>)  <EOL>return tau, pval, Concordant, Discordant, ExtraX, ExtraY<EOL>
List based implementation of binary tree algorithm for concordance
measure after :cite:`Christensen2005`.