Created
August 29, 2013 17:53
-
-
Save anonymous/6381240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pylab import * | |
from shogun.Mathematics import LogDetEstimator | |
from shogun.Mathematics import ProbingSampler | |
from shogun.Library import SerialComputationEngine | |
from shogun.Mathematics import LogRationalApproximationCGM | |
from shogun.Mathematics import RealSparseMatrixOperator | |
from shogun.Mathematics import LanczosEigenSolver | |
from shogun.Mathematics import CCGMShiftedFamilySolver | |
from shogun.Mathematics import Statistics | |
from scipy.sparse import csc_matrix | |
from scipy.sparse import spdiags | |
data=abs(randn(10)) | |
matrix=spdiags(data, 0, 10, 10); | |
print matrix | |
op=RealSparseMatrixOperator(csc_matrix(matrix)) | |
trace_sampler=ProbingSampler(op) | |
engine=SerialComputationEngine() | |
linear_solver=CCGMShiftedFamilySolver() | |
num_shifts=10 | |
eigen_solver=LanczosEigenSolver(op) | |
op_func=LogRationalApproximationCGM(op, engine, eigen_solver, linear_solver, num_shifts) | |
log_det_estimator=LogDetEstimator(trace_sampler, op_func, engine) | |
print sum(log(data)) | |
print Statistics.log_det(csc_matrix(matrix)) | |
print mean(log_det_estimator.sample(10000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment