HyperMath

NormRnd

NormRnd

Previous topic Next topic No expanding text in this topic  

NormRnd

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Generates random data from the normal probability distribution. There are two forms.

Syntax

RND = NormRnd(Mean, Std, Rows, Cols, Seed, State)

RND = NormRnd(Mean, Std, Seed, State)

Arguments

Name

Description

 

Mean(optional)

Mean of the distribution. A scalar, vector or matrix.

 

Std (optional)

Standard deviation of the distribution. A scalar, vector or matrix of positive values.

 

Rows

(optional)

Number of output rows. A positive integer. Only valid when Mean and Std are scalars.

 

Cols (optional)

Number of output columns. A positive integer. Only valid when Mean and Std are scalars.

 

Seed

(optional)

The seed to initialize the random number generator. A positive integer. See Comments below.

 

State (optional)

Set to "discard" if the state of the pseudo random number is not to be retained for future use. The default is "retain".

Output

Name

Description

 

RND

Random numbers from the normal distribution. Its dimensions are determined by the input arguments. See Comments below.

Example 1

Generate two random numbers from the normal distribution with (Mu, Sigma) pairs of (2, 5) and (4, 3) respectively, with a random seed of 2003.

 

Syntax

 

rnd = NormRnd([2,4],[5,3],2003)

 

Result

 

rnd = 1.8966    7.0872

Example 2

Generate a 1x4 vector of random numbers from the normal distribution with Mu = 2 and sigma = 5, and a random seed of 2003.

 

Syntax

 

rnd = NormRnd(2,5,1,4,2003)

 

Result

 

rnd = 1.8966    7.1453    -1.0218    11.607

Comments

Mean and Std must be the same size.

If Mean and Std are both omitted then Mean = 0 and Std = 1.

If the optional size inputs are omitted, the size of the output is solely determined by the size of the two inputs Mean and Std. Each entry in the output uses the corresponding entries in the two inputs.

If the optional size inputs are provided, both must be supplied. In that case Mean and Std must be scalars and the size of the output is determined by Rows and Cols. That is, the inputs Mean and Std are used for each element of the output.

The Seed can be any number. Using a seed allows a random sequence to be repeated.

See Also:

NormCDF

NormInvCDF

NormPDF

Probability Distributions