Skip to Main Content Skip to Search
Product Documentation

codistributed.randn - Create codistributed array of normally distributed random values

Syntax

RN = codistributed.randn(n)
RN = codistributed.randn(m, n, ...)
RN = codistributed.randn([m, n, ...])
RN = randn(n, codist)
RN = randn(m, n, codist)
RN = randn([m, n], codist)

Description

RN = codistributed.randn(n) creates an n-by-n codistributed array of normally distributed random values with underlying class double.

RN = codistributed.randn(m, n, ...) and RN = codistributed.randn([m, n, ...]) create an m-by-n-by-... codistributed array of normally distributed random values.

Optional arguments to codistributed.randn must be specified after the required arguments, and in the following order:

RN = randn(n, codist) is the same as RN = codistributed.randn(n, codist). You can also use the optional arguments with this syntax. To use the default distribution scheme, specify a codistributor constructor without arguments. For example:

spmd
    RN = codistributed.randn(8, codistributor1d());
end

RN = randn(m, n, codist) and RN = randn([m, n], codist) are the same as RN = codistributed.randn(m, n, ...) and RN = codistributed.randn([m, n, ...]), respectively. You can also use the optional arguments with this syntax.

Tips

When you use randn on the workers in the MATLAB pool, or 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,

spmd(4)
    RN = codistributed.randn(1000);
end

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

spmd(4)
    codist = codistributor('1d', 2, 1:numlabs);
    RN = randn(10, 10, 'uint16', codist);
end

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

See Also

codistributed.rand | codistributed.sprand | codistributed.sprandn | distributed.randn | randn

  


Free Parallel Computing Interactive Kit

See how to solve large problems with minimal effort and reduce simulation time.

Get free kit

Trials Available

Try the latest versions of parallel computing products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS