def cancorr(x1, x2, demean=True, standardize=False):
 if (demean or standardize):
  x1 = (x1 - x1.mean(0))
  x2 = (x2 - x2.mean(0))
 if standardize:
  x1 /= x1.std(0)
  x2 /= x2.std(0)
 t1 = np.linalg.pinv(x1).dot(x2)
 t2 = np.linalg.pinv(x2).dot(x1)
 m = t1.dot(t2)
 cc = np.sqrt(np.linalg.eigvals(m))
 cc.sort()
 return cc[::(-1)]

def cancorr ( x1 , x2 , demean = True , standardize = False ) : if ( demean or standardize ) : x1 = ( x1 - x1 . mean ( 0 ) ) x2 = ( x2 - x2 . mean ( 0 ) ) if standardize : x1 /= x1 . std ( 0 ) x2 /= x2 . std ( 0 ) t1 = np . linalg . pinv ( x1 ) . dot ( x2 ) t2 = np . linalg . pinv ( x2 ) . dot ( x1 ) m = t1 . dot ( t2 ) cc = np . sqrt ( np . linalg . eigvals ( m ) ) cc . sort ( ) return cc [ : : ( - 1 ) ]
canonical correlation coefficient beween 2 arrays parameters x1 .