Exemple #1
0
'''
Created on Feb 18, 2013

@author: tjhunter
'''

import numpy as np
from mm.arterial_hkt.gmrf_learning.utils import test_data
from mm.arterial_hkt.gmrf_learning.cvx import *

R = np.ones(5)
U = np.ones(3)
cols = np.array([2,3,4])
rows = np.array([0,0,0])
test_data(R, U, rows, cols)
edge_count = np.array([20,20,20])
min_variance=1e-2
min_edge_count = 0
gmrf_learn_cov_cvx(R, U, rows, cols, edge_count,min_variance,min_edge_count)
Exemple #2
0
  P = np.arange(m)/float(m)+1
  rows = np.zeros((n-1,),dtype=np.int)
  cols = np.arange(1,n,dtype=np.int)
  return (D,P,rows,cols)

(D,P,rows,cols) = star(5,4)
X = build_dense(D, P, rows, cols)
Xs = build_sparse(D, P, rows, cols)

l1 = logdet_dense(D, P, rows, cols)
l2 = logdet_dense_chol(D, P, rows, cols)
l3 = logdet_cholmod(D, P, rows, cols)

(M,Dn,Pn) = normalized_problem(D, P, rows, cols)

test_data(D, P, rows, cols)
W = la.inv(X)
#Q = random_projection_cholmod(D, U, rows, cols, k, factor)
Q = random_projection_cholmod_csc(Xs, k=1000)
A = Q.T
print A.shape
R = np.sum(A*A,axis=1)
U = np.sum(A[rows]*A[cols],axis=1)
R_ = W.diagonal()
U_ = W[rows,cols]

#X = build_sparse(D, P, rows, cols)
#(eis,_)=eigsh(X, k=1, sigma=-1, which='LM')
#ei = eis[0]

#is_psd_dense(R, U, rows, cols)