randn - Create codistributed array of normally distributed random numbers - MATLAB
Create codistributed array of normally distributed random numbers
Syntax
Description
creates an cR = randn(n,codist)n-by-n codistributed matrix
of normally distributed random numbers and uses codist to
specify the distribution of the array values across the workers. Each element in
cR is between 0 and 1.
Specify codist as "codistributed" to use the
default codistributor1d distribution scheme or the distribution scheme
defined by a codistributor1d or codistributor2dbc object.
When you create the codistributed array in a communicating job or spmd
block, the function creates an array on each worker. If you create a codistributed array
outside of a communicating job or spmd block, the array is stored only on
the worker or client that creates the codistributed array.
By default, the codistributed array has the underlying type double.
creates a codistributed array of normally distributed random numbers where the
size vector cR = randn(sz,codist)sz defines the size of cR.
For example, randn([2 3],"codistributed") creates a 2-by-3
codistributed array.
creates an cR = randn(sz1,...,szN,codist)sz1-by-...-by-szN codistributed
array of normally distributed random numbers where
sz1,...,szN indicates the size of each
dimension.
creates a codistributed array of normally distributed random numbers with the
underlying type cR = randn(___,datatype,codist)datatype. For example,
randn(1,"single","codistributed") creates a codistributed
single-precision random number. You can use this syntax with any of the size
arguments in the previous syntaxes. You must specify codist
after the array size and data type arguments.
creates a codistributed array of normally distributed random numbers without
using communication between workers.
cR = randn(___,"noCommunication")
When you create very large arrays or your communicating job or spmd
block uses many workers, worker-worker communication can slow down array creation. Use this
syntax to improve the performance of your code by removing the time required for
worker-worker communication.
Tip
When you use this syntax, some error checking steps are skipped. Use this syntax
to improve the performance of your code after you prototype your code without
specifying "noCommunication".
You must specify "noCommunication" after the size, data
type and codist arguments.
uses the array cR = randn(___,like=p)p to create a codistributed array of
normally distributed random numbers. You can also specify
"noCommunication" as part of the function call.
The returned array cR has the same underlying type,
sparsity, and complexity (real or complex) as p.
Examples
collapse all
Create a 1000-by-1000 codistributed double matrix of
randn values, distributed by its second dimension
(columns).
spmd(4) C = randn(1000,"codistributed"); end
With four workers, each worker contains a 1000-by-250 local piece of
C.
Create a 1000-by-1000 codistributed single matrix of
randn values, distributed by its columns.
spmd(4) codist = codistributorId(2,100*[1:spmdSize]); C = randn(1000,1000,"single",codist); end
Each worker contains a 100-by-spmdIndex local piece of
C.
Input Arguments
collapse all
Size of the square matrix, specified as an integer.
If
nis0, thencRis an empty matrix.If
nis negative, then the function treats it as0.
Distribution scheme for codistributed array, specified as one of these options:
"codistributed"— Uses the default distribution scheme defined by the defaultcodistributor1dobject.codistributor1dobject — Uses the one-dimensional distribution scheme defined in acodistributor1dobject. To use the default 1-D distribution scheme, you can specify thecodistributor1dfunction without arguments.codistributor2dbcobject — Uses the two-dimensional block-cyclic distribution scheme defined in acodistributor2dbcobject. To use the default 2-D block-cyclic distribution scheme, you can specify thecodistributor2dbcfunction without arguments.
Size of each dimension, specified as an integer row vector. Each element of this vector indicates the size of the corresponding dimension:
If the size of any dimension is
0, thencRis an empty array.If the size of any dimension is negative, then the function treats it as
0.Beyond the second dimension,
randnignores trailing dimensions with a size of1. For example,randn([3 1 1 1],"codistributed")produces a 3-by-1 codistributed vector of normally distributed random numbers.
Example: sz = [2 3 4] creates a 2-by-3-by-4
codistributed array.
Size of each dimension, specified as separate arguments of integer values.
If the size of any dimension is
0, thencRis an empty array.If the size of any dimension is negative, then the function treats it as
0.Beyond the second dimension, the function ignores trailing dimensions with a size of
1.
Underlying data type of the returned array, specified as one of these options:
"double""single""logical""int8""uint8""int16""uint16""int32""uint32""int64""uint64"
Prototype of array to create, specified as a codistributed array.
Output Arguments
collapse all
Underlying data type of the returned array, specified as one of these options:
"double""single""logical""int8""uint8""int16""uint16""int32""uint32""int64""uint64"
Prototype of array to create, specified as a codistributed array.
If you do not specify the datatype, the resulting
codistributed array has the same underlying type, sparsity, and complexity
(real or complex) as p.
Version History
Introduced in R2006b