distributed.sprandn
Create distributed sparse array of normally distributed pseudo-random values
Syntax
DS = distributed.sprandn(m,n,density)
DS = distributed.sprandn(___,typename)
Description
DS = distributed.sprandn(m,n,density)
creates an m
-by-n
sparse distributed array with approximately density*m*n
normally distributed nonzero double entries.
DS = distributed.sprandn(___,typename)
also specifies
the data type (class) of the sparse distributed array. The typename
input can be either "single"
or "double"
. (since R2025a)
Examples
Create a 1000-by-1000 sparse distributed double array DS
with approximately
1000 nonzeros.
DS = distributed.sprandn(1000,1000,0.001);
Create a random 500-by-1000 sparse distributed single-precision matrix with density 0.1.
DS = distributed.sprandn(500,1000,0.1,"single");
Tips
When you use sprandn
on the workers in the parallel pool, or in an independent or communicating job, each worker sets its random generator seed to a value that depends only on the spmdIndex
or task ID. Therefore, the array on each worker is unique for that job. However, if you repeat the job, you get the same random data.
Version History
Introduced in R2009bSee Also
sprandn
| codistributed.sprandn
| rand
| randn
| sparse
| distributed.speye
| distributed.sprand