(a, b, axis=0)
return C
Compute all pairwise Pearson product-moment correlation coefficients
    between rows or columns of a and b

    Parameters
    ----------
    a : (N, M) numpy.ndarray
        The input cases a.
    b : (J, K) numpy.ndarray
        The input cases b. In case of axis == 0: J must equal N;
        otherwise if axis == 1 then K must equal M.
    axis : int
        If 0 the correlation are computed between a and b's columns.
        Otherwise if 1 the correlations are computed between rows.

    Returns
    -------
    cor : (N, J) or (M, K) nd.array
        If axis == 0 then (N, J) matrix of correlations between a x b columns
        else a (N, J) matrix of correlations between a x b rows.

    See Also
    --------
    numpy.corrcoef
Compute all pairwise Pearson product-moment correlation coefficients
    between rows or columns of a and b
Compute all pairwise Pearson product - moment correlation coefficients between rows or columns of a and b
def _corrcoef2(a, b, axis=0):
    """
    Compute all pairwise Pearson product-moment correlation coefficients
    between rows or columns of a and b

    Parameters
    ----------
    a : (N, M) numpy.ndarray
        The input cases a.
    b : (J, K) numpy.ndarray
        The input cases b. In case of axis == 0: J must equal N;
        otherwise if axis == 1 then K must equal M.
    axis : int
        If 0 the correlation are computed between a and b's columns.
        Otherwise if 1 the correlations are computed between rows.

    Returns
    -------
    cor : (N, J) or (M, K) nd.array
        If axis == 0 then (N, J) matrix of correlations between a x b columns
        else a (N, J) matrix of correlations between a x b rows.

    See Also
    --------
    numpy.corrcoef
    """
    a, b = np.atleast_2d(a, b)
    if axis not in (0, 1):
        raise ValueError("Invalid axis {} (only 0 or 1 accepted)".format(axis))

    mean_a = np.mean(a, axis=axis, keepdims=True)
    mean_b = np.mean(b, axis=axis, keepdims=True)
    assert a.shape[axis] == b.shape[axis]

    n = a.shape[1 - axis]
    m = b.shape[1 - axis]

    a = a - mean_a
    b = b - mean_b

    if axis == 0:
        C = a.T.dot(b)
        assert C.shape == (n, m)
    elif axis == 1:
        C = a.dot(b.T)
        assert C.shape == (n, m)

    ss_a = np.sum(a ** 2, axis=axis, keepdims=True)
    ss_b = np.sum(b ** 2, axis=axis, keepdims=True)

    if axis == 0:
        ss_a = ss_a.T
    else:
        ss_b = ss_b.T

    assert ss_a.shape == (n, 1)
    assert ss_b.shape == (1, m)
    C /= np.sqrt(ss_a)
    C /= np.sqrt(ss_b)
    return C
def _corrcoef2 ( a , b , axis = 0 ) : a , b = np . atleast_2d ( a , b ) if axis not in ( 0 , 1 ) : raise ValueError ( "Invalid axis {} (only 0 or 1 accepted)" . format ( axis ) ) mean_a = np . mean ( a , axis = axis , keepdims = True ) mean_b = np . mean ( b , axis = axis , keepdims = True ) assert a . shape [ axis ] == b . shape [ axis ] n = a . shape [ 1 - axis ] m = b . shape [ 1 - axis ] a = a - mean_a b = b - mean_b if axis == 0 : C = a . T . dot ( b ) assert C . shape == ( n , m ) elif axis == 1 : C = a . dot ( b . T ) assert C . shape == ( n , m ) ss_a = np . sum ( a ** 2 , axis = axis , keepdims = True ) ss_b = np . sum ( b ** 2 , axis = axis , keepdims = True ) if axis == 0 : ss_a = ss_a . T else : ss_b = ss_b . T assert ss_a . shape == ( n , 1 ) assert ss_b . shape == ( 1 , m ) C /= np . sqrt ( ss_a ) C /= np . sqrt ( ss_b ) return C