The method available in python scipy sps.rand() generates sparse matrix of random values in the range (0,1). How can we generate discrete random values greater than 1 like 2, 3,etc. ? Any method in scipy, numpy ?
-
By using the other method defined.sascha– sascha2016-10-26 14:36:21 +00:00Commented Oct 26, 2016 at 14:36
1 Answer
sparse.rand calls sparse.random. random adds a optional data_rvs.
I haven't used data_rvs. It can probably emulate the dense randint, but definition is more complicated.
Another option is to generate the random floats and then convert them with a bit of math to the desired integers. You have to be a little careful since some operations will produce a Sparse Efficiency warning. You want operations that will change the nonzero values without touching the zeros.
(I suspect the data_rvs parameter was added in newer Scipy version, but I don't see an indication in the docs).