コード例 #1
0
ファイル: util.py プロジェクト: argriffing/fels-reml-jan-2014
def restored(A):
    """
    @param A: full rank symmetric matrix whose rows sum to 1
    @return: a doubly centered but otherwise full rank matrix
    """
    assert_symmetric(A)
    n = A.shape[0]
    return A - ones_like(A) / n
コード例 #2
0
def get_selection_S(F):
    """
    The F and S notation is from Yang and Nielsen 2008.
    @param F: a selection value for each codon, up to an additive constant
    @return: selection differences F_j - F_i, also known as S_ij
    """
    e = algopy.ones_like(F)
    return algopy.outer(e, F) - algopy.outer(F, e)
コード例 #3
0
ファイル: mle-recessive-slsqp.py プロジェクト: BIGtigr/xgcode
def get_selection_S(F):
    """
    The F and S notation is from Yang and Nielsen 2008.
    @param F: a selection value for each codon, up to an additive constant
    @return: selection differences F_j - F_i, also known as S_ij
    """
    e = algopy.ones_like(F)
    return algopy.outer(e, F) - algopy.outer(F, e)
コード例 #4
0
ファイル: util.py プロジェクト: argriffing/fels-reml-jan-2014
def augmented(A):
    """
    @param A: doubly centered symmetric nxn matrix of rank n-1
    @return: full rank symmetric matrix whose rows sum to 1
    """
    assert_square(A)
    n = A.shape[0]
    #assert_allclose(dot(ones(n), A), zeros(n), atol=1e-12)
    #assert_allclose(dot(A, ones(n)), zeros(n), atol=1e-12)
    return A + ones_like(A) / n
コード例 #5
0
ファイル: codon_model.py プロジェクト: eteq/algopy
def get_selection_S(F):
    """
    The F and S notation is from Yang and Nielsen 2008.
    Speed matters.
    @param F: a selection value for each codon, up to an additive constant
    @return: selection differences F_j - F_i, also known as S_ij
    """

    # FIXME: use algopy.ones_like when it becomes available
    e = algopy.ones_like(F)

#     # FIXME: instead of the following block
#     e = algopy.zeros_like(F)
#     for i in range(F.shape[0]):
#         e[i] = 1.

    return algopy.outer(e, F) - algopy.outer(F, e)