rand

Create distributed array of uniformly distributed pseudo-random numbers

Syntax

D = rand(n, dist)
D = rand(m, n, dist)
D = rand([m, n], dist)
D = rand(..., classname, dist)

Description

D = rand(n, dist) creates an n-by-n distributed array of underlying class double. D is distributed by dimension dim, where dim = distributionDimension(dist), and with partition PAR, where PAR = distributionPartition(dist). If dim is unspecified, then D is distributed by its second dimension. If PAR is unspecified, then 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 eye.

D = rand(m, n, dist) and D = rand([m, n], dist) create an m-by-n distributed array of underlying class double. The distribution dimension dim and partition PAR can be specified by dist as above, but if they are not specified, dim is taken to be the last nonsingleton dimension of D, and PAR is provided by defaultPartition over the size in that dimension.

D = rand(..., classname, dist) optionally specifies the class of the distributed array D. Valid choices are the same as for the regular rand function: 'double' (the default), 'single', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', and 'uint64'.

Remarks

When you use rand 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.

Examples

With four labs,

D = rand(1000, distributor())

creates a 1000-by-1000 distributed double array D, distributed by its second dimension (columns). Each lab contains a 1000-by-250 local piece of D.

D = rand(10, 10, 'uint16', distributor('1d', 2, 1:numlabs))

creates a 10-by-10 distributed uint16 array D, distributed by its columns. Each lab contains a 10-by-labindex local piece of D.

See Also

rand MATLAB® function reference page

cell, eye, false, Inf, NaN, ones, randn, sparse, speye, sprand, sprandn, true, zeros

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS