fastRTG: Fast Sampling for Random Tensor Graphs

Description Usage Arguments Value Examples

View source: R/fastRTG.R

Description

Provide efficient algorithm to sample various random tensor graphs. This function allows general low-rank tensor setup in the sense that the core tensor can has arbitrary number of modes and different number of latent factors in each modes (Tucker Decomposition).

Usage

1
fastRTG(X, G, sparsity = NULL, PoissonEdges = TRUE, returnParameters = FALSE)

Arguments

X

a list of matrices X_i's. Each X_i is a n_i by k_i matrix. n_i is the dimension size in the i-th mode. k_i is the number of latent factors in the i-th mode. If X only has one matrix, the default reads it as a 3-mode tensor with same X_1 in all three modes.

G

the core tensor represented by a multi-dimensional array. Should not contain negative values.

PoissonEdges

boolean indicator. Allow poisson edges if TRUE, otherwise only binary edges.

returnParameters

return parameter list or not.

avgDeg

specifies the expected degree.

Value

if returnParameters is TRUE, returns a list containing sampled tensor as well as the ground truth latent factors X, core tensor G. The sampled tensor is a tensorr::sptensor object. The latent factors is a list of matrices. The core tensor is a rTensor::Tensor object.

Examples

1
2
3
4
5
6
G = array(rgamma(120,1,1), dim = c(2,3,4,5))
X[[1]] = matrix(abs(rnorm(20)),10,2)
X[[2]] = matrix(rgamma(60,1,1),20,3)
X[[3]] = matrix(rf(120,3,4),30,4)
X[[4]] = matrix(1,40, 5)
sampleTensor <- fastRTG(X, G, sparsity = 0.01, returnParameters = TRUE)

MuzheZeng/fastRTG documentation built on May 12, 2020, 1:43 p.m.