Reputation: 1468
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 ?
Upvotes: 0
Views: 335
Reputation: 231355
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).
Upvotes: 1