Builds an ensemble of LaplacianScorer objects that can be used to score functions and to sample scores by shuffling point labels in tandem.
new
Constructs a scorer ensemble using lists containing data on the complex
and their laplacians.
Use scorer.ensemple <- new(ScorerEnsemble, comb_laplacian, pts_in_vertex, adjacency, one_forms)
Parameters
comb_laplacian
: List containing outputs of combinatorial_laplacian
pts_in_vertex
: List of lists of vectors where the i-th vector of the j-th list
contains the index of the points associated to the i-th vertex of the j-th complex
adjacency
: List of adjacency matrices for 1-skeleton as a sparse matrix
one_forms
: boolean indicating if laplacian of one-forms will be computed
score
Pushes functions defined by rows of funcs to the dim-skeleton of all complexes by
averaging and computes its laplacian score.
Use scorer$score(funcs, dim)
Parameters
funcs
: functions to be scored as a rows of a dense matrix
dim
: dimension of the laplacian (0 or 1)
Value Scores of functions as a matrix. The value in position (i,j) is the score of the i-th function on the j-th complex.
sample_scores
Takes samples of scores by permuting point labels
Use scorer$sample_scores(funcs, n_perm, dim, n_cores)
Parameters
funcs
: base functions as rows of a dense matrix
n_perm
: number of permutations
dim
: dimension of the laplacian
n_cores
: number of cores to be used, parallelization requires code to be compiled with openmp
Value Dense 3-dimensional array with sampled scores where position (i,j,k) has the score of the j-th permutation of the i-th function in the k-th complex.
sample_with_covariate
Takes samples of scores of function in tandem with scores of covariates
by applying the same permutations of labels to both.
Use scorer$sample_with_covariate(funcs, cov, n_perm, dim, n_cores)
Parameters
funcs
: base functions as rows of a dense matrix
cov
: covariates as rows of a dense matrix
n_perm
: number of permutations
dim
: dimension of the laplacian
n_cores
: number of cores to be used, parallelization requires code to be compiled with openmp
Value A list out
with as many elements as there are complexes in the ensemble. Each element
of the list is itself a list with two elements:
func_scores
: a dense matrix with sampled scores where the
i-th row has samples for the i-th function.
cov_scores
: a dense 3-dimensional array where the position (i, j, k) has the sampled score
of the j-th covariate associated to the k-th sample of the i-th function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | library(RayleighSelection)
# Create a simplicial complex and compute the associated 0- and 1-laplacians
gy.list <- list(
nerve_complex(list(c(1,4,6,10), c(1,2,7), c(2,3,8), c(3,4,9,10), c(4,5))),
nerve_complex(list(c(1,6,10), c(1,4,2,7), c(2,3,8), c(3,4,9,10), c(4,5)))
)
lout.list <- lapply(gy.list, combinatorial_laplacian, one_forms = TRUE)
# Create an associated instance of ScorerEnsemble
scorer.ensemble <- new(
ScorerEnsemble,
lout.list,
lapply(gy.list, function(gy) gy$points_in_vertex),
lapply(gy.list, function(gy) gy$adjacency),
TRUE
)
# Compute the 0-laplacian scores of a a function
scorer.ensemble$score(t(as.matrix(c(0,1,1,0,0,0,0,0,0,1))), 0)
# Sample scores by shuffling the function
scorer$sample_scores(t(as.matrix(c(0,1,1,0,0,0,0,0,0,1))), 10, 0, 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.