| Parallel Computing Toolbox™ | ![]() |
Create distributed sparse array of normally distributed random values
D = sprandn(m, n, density, dist)
D = sprandn(m, n, density, dist) creates an m-by-n sparse distributed array with approximately density*m*n normally distributed nonzero double entries. D is distributed by dimension dim, where dim = distributionDimension(dist), and with partition PAR, where PAR = distributionPartition(dist). If dim is unspecified, D is distributed by its second dimension. If PAR is unspecified, D uses defaultPartition(n) as its partition. The easiest way to do this is to use a default distributor where both dim and PAR are unspecified (dist = distributor()) as input to sprandn.
When you use sprandn in a distributed or parallel job (including pmode), each worker or lab sets its random generator seed to a value that depends only on the lab index or task ID. Therefore, the array on each lab is unique for that job. However, if you repeat the job, you get the same random data.
With four labs,
D = sprandn(1000, 1000, .001, distributor())
creates a 1000-by-1000 sparse distributed double array D with approximately 1000 nonzeros. D is distributed by its second dimension (columns), and each lab contains a 1000-by-250 local piece of D.
D = sprandn(10, 10, .1, distributor('1d', 2, 1:numlabs))creates a 10-by-10 distributed double array D with approximately 10 nonzeros. D is distributed by its columns, and each lab contains a 10-by-labindex local piece of D.
sprandn MATLAB® function reference page
cell, eye, false, Inf, NaN, ones, rand, randn, sparse, speye, sprand, true, zeros
![]() | sprand | submit | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |