def cor(x,y=None):
    '''
    A function that simply computes the correlation matrix: Corr(X,Y).  Data points 
    should be stored in rows.  This function should have similar conventions
    and results as the R function of the same name.
    
    @param x: a matrix containing data.
    @type x: np.array
    @param y: an optional second matrix.  By default y = x.
    @type x: np.array
    '''
    if y == None:
        y = x
    x = copy.deepcopy(x)
    y = copy.deepcopy(y)
    nx,dx = x.shape
    n,dy = y.shape
    
    assert nx == n
    
    mx = x.mean(axis=0).reshape(1,dx)
    my = y.mean(axis=0).reshape(1,dy)
    sx = x.std(axis=0,ddof=1).reshape(1,dx)
    sy = y.std(axis=0,ddof=1).reshape(1,dy)
    x = (x-mx)/sx
    y = (y-my)/sy
    s = 1.0/(n-1)
    return s*np.dot(x.T,y)
dataset/ETHPy150Open bolme/pyvision/src/pyvision/analysis/stats.py/cor/original