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))
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
评论列表
文章目录