randn

Generate standard normal random values.

Syntax

r = randn()

r = randn(n)

r = randn(m,n,...)

r = randn([m,n,...])

rand('seed',seed)

v = rand('state')

rand('state',v)

Inputs

m, n, ...
The length of each dimension in the output matrix.
Type: integer
Dimension: scalar
seed
A seed value to initialize the random number generator.
Type: non-negative integer
Dimension: scalar
v
A vector containing the state of the random number generator.
Type: integer
Dimension: vector

Outputs

r
Standard normal random values.
v
A vector containing the state of the random number generator.
Type: integer
Dimension: vector

Example

Square matrix examples:
randn('seed',0);
r = randn(3)
r = [Matrix] 3 x 3
1.16308  0.77400   0.15303
2.21221  0.29956   1.18393
0.48380  1.04344  -1.16881
Rectangular matrix example:
randn('seed',0);
r = randn(2,4)
r = [Matrix] 2 x 4
1.16308  0.48380  0.29956  0.15303
2.21221  0.77400  1.04344  1.18393

Comments

randn() generates scalar outputs.

randn(n) generates a square matrix.

The seed value initializes the generator state and has no post-initialization significance. It does not update as the generator is used, as happens in some generators. If the seed is not set it defaults to 0 the first time that the generator is used.

The state vector can be accessed and restored later if more than one random sequence is desired. The user should not attempt to create state vectors otherwise than by setting seed values.