コード例 #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
ファイル: farray_test.py プロジェクト: kwgoodman/la
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
ファイル: farray_test.py プロジェクト: kwgoodman/la
def test_covMissing_1():
    "farray.covMissing_1"
    a = np.ones((2,10))
    actual = covMissing(a)
    desired = np.ones((2,2))
    aae(actual, desired)