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.
- seed
- A seed value to initialize the random number generator.
- v
- A vector containing the state of the random number generator.
Outputs
- r
- Standard normal random values.
- v
- A vector containing the state of the random number generator.
Example
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
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.