simulate_sparse_matrix | R Documentation |
This function generates a sparse matrix with a specified number of rows and columns, a given sparsity level, and a distribution function for the non-zero values.
simulate_sparse_matrix(
nrow,
ncol,
sparsity = 0.95,
distribution_fun = function(n) stats::rpois(n, lambda = 0.5) + 1,
decimal = 0,
seed = 1
)
nrow |
Number of rows in the matrix. |
ncol |
Number of columns in the matrix. |
sparsity |
Proportion of zero elements (sparsity level). Default is 0.95, meaning 95% of elements are zero (5% are non-zero). |
distribution_fun |
Function to generate non-zero values. |
decimal |
Numeric value, default is |
seed |
Random seed for reproducibility. |
A sparse matrix of class "dgCMatrix"
simulate_sparse_matrix(1000, 500) |>
check_sparsity()
simulate_sparse_matrix(10, 10, decimal = 1)
simulate_sparse_matrix(10, 10, decimal = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.