SynGraphPN.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:TVGL 作者: davidhallac 项目源码 文件源码
def genCovariace(size): 
    MaxIter = 1e+6
    S = np.zeros((size,size))
    itn = 0
    while(alg.det(S) <= 1e-3 and itn < MaxIter):
        itn = itn + 1
        #print int(numpy.log2(size))*size
        G6 = GenRndGnm(PUNGraph, size, int((size*(size-1))*0.05))
        #G6 = snap.GenRndGnm(snap.PUNGraph, 5, 5)
        S = np.zeros((size,size))
        for EI in G6.Edges():
            S[EI.GetSrcNId(), EI.GetDstNId()] = 0.6
        S =  S + S.T + S.max()*np.matrix(np.eye(size))
    if itn == MaxIter:
        print 'fail to find an invertible sparse inverse covariance matrix'
    S = np.asarray(S)
    return S
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号