normrnd

Generate random data from a normal distribution.

Syntax

rnd=normrnd()

rnd=normrnd(mu,sigma)

rnd=normrnd(mu,sigma,r,c)

rnd=normrnd(mu,sigma,d1,d2,...dN)

rnd=normrnd(mu,sigma,[d1,d2,...dN])

Inputs

mu
Mean (default = 0).
Type: double
Dimension: scalar | vector | matrix
sigma
Standard Deviation (default = 1).
Type: double
Dimension: scalar | vector | matrix
r, c, d1, d2, dN, etc.
The dimension inputs, which in 2D are the number of rows and columns.
Type: integer
Dimension: scalar

Outputs

rnd
Random data.

Examples

Single value normrnd example:

mu = 5;
sigma = 3;
rnd = normrnd(mu,sigma);
rnd = 8.4892
Vector normrnd example:
mu = 5;
sigma = 3;
r = 1;
c = 5;
rnd = normrnd(mu,sigma,r,c);
rnd = [Matrix] 1 x 5
8.4892 11.637 6.4514 7.322 5.8987

Comments

The random number generator can be initialized using rand or randn.