Create Random Sparse Matrices
random.RdCreates random spam matrix given the dimension and other parameters.
Usage
spam_random(nrow = 1L, ncol = nrow, density = 0.5, distribution = NULL, digits = NULL,
sym = FALSE, spd = FALSE, verbose = FALSE, ...)Arguments
- nrow
integer value for the number of rows for the
spammatrix to create.- ncol
integer value for the number of columns. The default value is the same as
nrow.- density
A numeric value between 0 and 1 specifying the approximate density of matrix. If equal to zero the
spammatrix contains only zeros and if equal to 1 thespammatrix is full.- distribution
a random number generating distribution function to sample the entries of the
spammatrix. The function must have an argument with the namen, possible candidates arernorm,rexp,rpois,rweibull, etc. Default (NULL) fills with ones.- ...
possible additional arguments for the distribution function if specified with
distribution.- digits
an integer value for the number of digits the entries should be rounded.
- sym
logical value to specify symmetry of the
spammatrix.- spd
logical value to specify positive definitness of the
spammatrix, via diagonal dominace criteria. Note, ifspdTRUE, thensymis overwritten toTRUEin any case.- verbose
logical value to specify verbose statments of the function.
Examples
set.seed(42)
rspam <- spam_random(500, digits = 2, distribution = rnorm, sd = 2, mean = 10, density = .01)
display.spam(rspam, cex = 2)