示例#1
0
文件: flarry.py 项目: gaybro8777/la
def cov(lar):
    """
    Covariance matrix adjusted for missing (NaN) values.
    
    Note: Only works on 2d larrys.
    
    The mean of each row is assumed to be zero. So rows are not demeaned
    and therefore the covariance is normalized by the number of columns,
    not by the number of columns minus 1.        
    
    Parameters
    ----------
    lar : larry
        The larry you want to find the covariance of.
        
    Returns
    -------
    out : larry
        For 2d input of shape (N, T), for example, returns a NxN covariance
        matrix.
        
    Raises
    ------
    ValueError
        If input is not 2d    

    """
    if lar.ndim != 2:
        raise ValueError, 'This function only works on 2d larrys'
    y = lar.copy()
    y.label[1] = list(y.label[0])
    y.x = covMissing(y.x)
    return y
示例#2
0
文件: flarry.py 项目: josef-pkt/la
def cov(lar):
    """
    Covariance matrix adjusted for missing (NaN) values.
    
    Note: Only works on 2d larrys.
    
    The mean of each row is assumed to be zero. So rows are not demeaned
    and therefore the covariance is normalized by the number of columns,
    not by the number of columns minus 1.        
    
    Parameters
    ----------
    lar : larry
        The larry you want to find the covariance of.
        
    Returns
    -------
    out : larry
        For 2d input of shape (N, T), for example, returns a NxN covariance
        matrix.
        
    Raises
    ------
    ValueError
        If input is not 2d    

    """
    if lar.ndim != 2:
        raise ValueError, 'This function only works on 2d larrys'      
    y = lar.copy()
    y.label[1] = list(y.label[0])
    y.x = covMissing(y.x)
    return y
示例#3
0
def test_covMissing_2():
    "farray.covMissing_2"
    a = np.ones((2, 4))
    a[0, 1] = np.nan
    b = a.copy()
    ignore = covMissing(a)
    aae(a, b)
示例#4
0
def test_covMissing_2():
    "farray.covMissing_2"
    a = np.ones((2,4))
    a[0,1] = np.nan
    b = a.copy()
    ignore = covMissing(a)
    aae(a, b)
示例#5
0
def test_covMissing_1():
    "farray.covMissing_1"
    a = np.ones((2, 10))
    actual = covMissing(a)
    desired = np.ones((2, 2))
    aae(actual, desired)
示例#6
0
def test_covMissing_1():
    "farray.covMissing_1"
    a = np.ones((2,10))
    actual = covMissing(a)
    desired = np.ones((2,2))
    aae(actual, desired)