rsim_data: Simulate a data matrix of a given dimension and rank for PCP...

View source: R/rsim_data.R

rsim_dataR Documentation

Simulate a data matrix of a given dimension and rank for PCP experiments.

Description

rsim_data simulates a data matrix, M, of a given dimension and rank by simulating ground truth low rank (L), sparse (S) and noise (Z) components. Meaning M = L + S + Z. The M, L, S and Z matrices are all accessible from this function, allowing for easy evaluation of PCP's performance.

Usage

rsim_data(
  sim_seed,
  nrow,
  ncol,
  rank,
  sigma,
  add_sparse = FALSE,
  nonneg = TRUE,
  ldist = runif,
  sdist = runif,
  zdist = rnorm,
  ...
)

Arguments

sim_seed

Required seed to allow for reproducible results & distinct simulated matrices.

nrow

Sets number of rows in the simulated data matrix.

ncol

Sets the number of columns in the simulated data matrix.

rank

Sets the rank of the simulated data matrix.

sigma

Sets the standard deviation of the noise matrix, Z.

add_sparse

Logical that sets whether sparse noise, S, is added or not. Default=FALSE.

nonneg

Logical that sets whether the final M matrix should be non-negative. Default=TRUE.

ldist

Function that defines a distribution to use when simulating the L matrix. Default=runif.

sdist

Function that defines a distribution to use when simulating the S matrix. Default=runif.

zdist

Function that defines a distribution to use when simulating the Z matrix. Default=rnorm.

Value

list containing the simulated M, L, S and Z matrices.

Examples

data <- rsim_data(sim_seed = 1, nrow = 10, ncol = 10, rank = 3, sigma = .1, add_sparse = TRUE)

Columbia-PRIME/PCPhelpers documentation built on April 24, 2022, 7:57 p.m.